pycopancore.model_components.base.model_logics module

base component’s Model component mixin class and essential framework logics.

This class is the Model component mixin of the base model component and also owns the configure method. This method is central to the framework since it fuses together the used classes and puts information about process types and variables in special list to be accessed by the runner.

exception ConfigureError[source]

Bases: Exception

Define Error.

class ModelLogics(*, reconfigure=False, **kwargs)[source]

Bases: object

Model logics class.

Provide the configure method. The configure method has a very central role in the COPAN:core framework, it is called before letting run a model. It then searches which model class is used from the model module. It will then go through all components listed there and collect all variables and processes of said components.

ODE_dependencies = None

dict giving for each ODE target variable the set of vars occurring on RHS of equation

ODE_processes = None

ordered set of processes of type ODE

ODE_targets = None

ordered set of targets or _AttributeReferences changed by processes of type ODE

_configured = False

whether model was configured already

components = None

ordered set of model components in method resolution order

classmethod configure(reconfigure=False, **kwargs)[source]

Configure the model.

This classmethod configures the model by analysing the model’s and all its entity types’ and process taxa’s class inheritance structure to find all mixin classes (implementation and interface), analyse them to compile and output lists (actually OrderedSets) of variables and processes.

Parameters:

reconfigure (bool) – Flag that indicates if the model should be reconfigured even if it is already configured

convert_to_standard_units()[source]

Replace all variable values of type DimensionalQuantity to float.

Using the standard unit. This is mainly done for performance reasons.

event_processes = None

ordered set of processes of type Event

event_variables = None

ordered set of Variables changed by processes of type Event

explicit_dependencies = None

dict giving for each explicit target variable the set of vars occurring on RHS of equation

explicit_evaluation_order = None

list of explicit target Variables in planned order of evaluation

explicit_processes = None

ordered set of processes of type Explicit

explicit_targets = None

ordered set of targets controlled by processes of type Explicit

mixin2composite = None

dict mapping mixins to derived composite classes

process_targets = None

ordered set of Variables or _AttributeReferences changed by any process

processes = None

ordered set of processes

reset()[source]

Reset all varaibles back to default values.

step_processes = None

ordered set of processes of type Step

step_variables = None

ordered set of Variables changed by processes of type Step

variables = None

ordered set of Variables occurring in the model

guess_deps(method, variable_pool)[source]

guess the dependencies of a process’ target variable from searching its’ specification method for known variable codenames