pihnn.utils#

Utilities for building and training PIHNNs.

Functions#

get_complex_input(input_value)

Convert the input value to the unified format (i.e., complex torch.tensor).

get_complex_function(func)

Convert the input function to the unified format (i.e., callable: complex torch.tensor -> complex torch.tensor).

derivative(f, z[, holom, conjugate])

Compute the derivative \(\frac{df}{dz}\) through PyTorch automatic differentiation.

MSE(value[, true_value])

Mean squared error (MSE). Equivalent to torch.nn.MSELoss() except it takes into account empty inputs.

PIHNNloss(boundary, model, t)

Evaluation of the loss function as Mean squared error (MSE).

scalar_loss(boundary, model, t)

Called by pihnn.utils.PIHNNloss() if one aims to solve the Laplace or biharmonic problem.

km_loss(boundary, model, t)

Called by pihnn.utils.PIHNNloss() if one aims to solve the linear elasticity problem

train(boundary, model, n_epochs[, learn_rate, ...])

Performs the training of the neural network.

compute_Lp_error(triangulation, model, model_true[, p])

Compute and print to screen the approximated relative \(L^p\) error between a model and a reference solution. I.e.,