CubicTemplate.add_model(propname, model, domain='all', regen_mode='normal', **kwargs)#

Add a pore-scale model to the object, along with the desired arguments

  • propname (str) – The name of the property being computed. E.g. if propname='pore.diameter' then the computed results will be stored in obj['pore.diameter'].

  • model (function handle) – The function that produces the values

  • domain (str) – The label indicating the locations in which results generated by model should be stored. See Notes for more details.

  • regen_mode (str) –

    How the model should be regenerated. Options are:




    (default) The model is run immediately upon being added, and is also run each time regenerate_models is called.


    The model is NOT run when added, but is run each time regenerate_models is called. This is useful for models that depend on other data that may not exist yet.


    The model is run immediately upon being added, but is is not run when regenerate_models is called, effectively turning the property into a constant.

  • kwargs (keyword arguments) – All additional keyword arguments are passed on to the model


The domain argument dictates where the results of model should be stored. For instance, given propname='pore.diameter' and domain='left' then when model is run, the results are stored in in the pores labelled left. Note that if model returns Np values, then values not belonging to 'pore.left' are discarded. The following steps outline the process:

  1. Find the pore indices:

Ps = obj.pores('left')
  1. Run the model:

vals = model(**kwargs)

3. If the model returns a full Np-length array, then extract the correct values and apply them to the corresponding locations:

if len(vals) == obj.Np:
    obj['pore.diameter'][Ps] = vals[Ps]
  1. If the model was designed to return only the subset of values then:

if len(vals) == obj.num_pores('left'):
    obj['pore.diameter'][Ps] = vals