pinnicle

pinnicle.pinn module

class pinnicle.pinn.PINN(params={}, loadFrom=None)[source]

Bases: object

a basic PINN model

apply_transfer_learning(cfg=None)[source]

load pretrained weights + freeze parameters based on cfg

cfg can be: -dict (from params.param_dict[“transfer_learning”]) -object with attributes (enabled, weights_path, freeze,etc)

check_path(path, loadOnly=False)[source]

check the path, set to default, and create folder if needed

compile(opt=None, epochs=None, loss=None, lr=None, loss_weights=None, decay=None)[source]

compile the model, the main purpose is to check if the current setting works for the training

find_closest_model_file(path, subfolder='pinn', name='model', epochs=0, fileformat='')[source]

Find files in {path}/{subfolder}/ with filename format:

{name}-{integer_epoch}.{extension}

Then return the file with the largest integer_epoch <= epochs.

If file not found, will chose a backup model such that the difference in epochs is a tenth of the number of training epochs

load_model(path='', epochs=-1, subfolder='pinn', name='model', fileformat='')[source]

load the neural network from saved model

load_setting(path='', filename='params.json')[source]

load the settings from file

plot_history(path='')[source]

plot training history

plot_predictions(path='', filename='2Dsolution.png', **kwargs)[source]

plot model predictions

Parameters:
  • path (Path, str) – Path to save the figures

  • filename (str) – name to save the figures, if set to None, then the figure will not be saved

  • X_ref (dict) – Coordinates of the reference solutions, if None, then just plot the predicted solutions

  • u_ref (dict) – Reference solutions, if None, then just plot the predicted solutions

  • cols (int) – Number of columns of subplot

save_history(path='')[source]

save training history

save_model(path='', subfolder='pinn', name='model')[source]

save the neural network to the hard disk

save_setting(path='', subfolder='pinn')[source]

save settings from self.params.param_dict

setup()[source]

setup the model according to self.params from the constructor

train(iterations=0)[source]

train the model

update_callbacks(params=None)[source]

update callback functions for the training according to the settings in params

update_parameters(params)[source]

update self.params according to the input params. If key already exists, update the value; if not, add the pair

update_training_data(training_data)[source]

update data set used for the training, the order follows ‘output_variables’

pinnicle.parameter module

class pinnicle.parameter.DataParameter(param_dict={})[source]

Bases: ParameterBase

list of all data used

check_consistency()[source]

check consistency of the parameter data

set_default()[source]

default parameters

update()[source]

convert dict to class SingleDataParameter

class pinnicle.parameter.DomainParameter(param_dict={})[source]

Bases: ParameterBase

parameters of domain

check_consistency()[source]

need to provide start and end time if solving a time dependent problem

set_default()[source]

set default values

class pinnicle.parameter.EquationParameter(param_dict={})[source]

Bases: ParameterBase

parameter of equations

check_consistency()[source]

check consistency of the parameter data

classmethod create(equation_type, **kwargs)[source]
set_default()[source]

set default values

set_parameters(pdict: dict)[source]

overwrite the default function, so that for ‘scalar_parameters’, only update the dict

subclasses = {'CalvingFront': <class 'pinnicle.physics.boundaryconditions.CalvingFrontBCEquationParameter'>, 'DUMMY': <class 'pinnicle.physics.dummy.DummyEquationParameter'>, 'MC': <class 'pinnicle.physics.continuity.MCEquationParameter'>, 'MC4MOLHO': <class 'pinnicle.physics.continuity.MC4MOLHOEquationParameter'>, 'MOLHO': <class 'pinnicle.physics.stressbalance.MOLHOEquationParameter'>, 'MOLHO Taub': <class 'pinnicle.physics.stressbalance.MOLHOTauEquationParameter'>, 'Mass transport': <class 'pinnicle.physics.continuity.ThicknessEquationParameter'>, 'SSA': <class 'pinnicle.physics.stressbalance.SSAEquationParameter'>, 'SSA First': <class 'pinnicle.physics.stressbalance.SSAFirstEquationParameter'>, 'SSA Taub': <class 'pinnicle.physics.stressbalance.SSATauEquationParameter'>, 'SSA_SHELF': <class 'pinnicle.physics.iceshelf.SSAShelfEquationParameter'>, 'SSA_SHELF_VB': <class 'pinnicle.physics.iceshelf.SSAShelfVariableBEquationParameter'>, 'SSA_VB': <class 'pinnicle.physics.stressbalance.SSAVariableBEquationParameter'>, 'Time_Invariant': <class 'pinnicle.physics.timeinvariant.TimeInvariantConstraintParameter'>, 'Weertman': <class 'pinnicle.physics.friction.WeertmanFrictionParameter'>}
class pinnicle.parameter.LossFunctionParameter(param_dict={})[source]

Bases: ParameterBase

parameter of customize loss function

check_consistency()[source]

check consistency of the parameter data

set_default()[source]

set default values

class pinnicle.parameter.NNParameter(param_dict={})[source]

Bases: ParameterBase

parameters of nn

check_consistency()[source]

check consistency of the parameter data

is_input_scaling()[source]

if the input boundaries are provided, or fourier feature transform is used

is_output_scaling()[source]

if the output boundaries are provided

set_default()[source]

default values:

set_parameters(pdict: dict)[source]

find all the keys from pdict which are avalible in the class, update the values

class pinnicle.parameter.ParameterBase(param_dict)[source]

Bases: ABC

Abstract class of parameters in the experiment

abstractmethod check_consistency()[source]

check consistency of the parameter data

has_keys(keys)[source]

if all the keys are in the class, return true, otherwise return false

abstractmethod set_default()[source]

set default values

set_parameters(pdict: dict)[source]

find all the keys from pdict which are avalible in the class, update the values

update()[source]

after set_parameter, make some necessary update of the parameters

class pinnicle.parameter.Parameters(param_dict={})[source]

Bases: ParameterBase

parameters of the pinn, including domain, data, nn, and physics

check_consistency()[source]

check consistency of the parameter data

set_default()[source]

set default values

set_parameters(param_dict)[source]

find all the keys from pdict which are avalible in the class, update the values

update()[source]

update parameters according to the input

class pinnicle.parameter.PhysicsParameter(param_dict={})[source]

Bases: ParameterBase

parameter of physics

check_consistency()[source]

check consistency of the parameter data

set_default()[source]

set default values

setup_equations()[source]

translate the input dict to subclass of EquationParameter(), and save back to the values in self.equations

class pinnicle.parameter.SingleDataParameter(param_dict={})[source]

Bases: ParameterBase

parameters of a single data file

check_consistency()[source]

check consistency of the parameter data

set_default()[source]

default settings

update()[source]

update name_map according to data_size

class pinnicle.parameter.TrainingParameter(param_dict={})[source]

Bases: ParameterBase

parameter of training

check_callbacks()[source]

check if any of the following variable is given from setting

check_consistency()[source]

check consistency of the parameter data

has_EarlyStopping()[source]

check if param has the min_delta or patience for early stopping

has_MiniBatch()[source]

check if param has mini batch

has_ModelCheckpoint()[source]

check if param has checkpoint=True for checkpointing

has_PDEPointResampler()[source]

check if param has the period for resampler

set_default()[source]

set default values

update()[source]

convert dict to class LossFunctionParameter