openpnm.models.physics.source_terms.general_symbolic(target, eqn, x, **kwargs)[source]

A general function to interpret a sympy equation and evaluate the linear components of the source term.

  • target (OpenPNM Base object) – Object with which this model is associated. This controls the length of the calculated array, and also provides access to other necessary properties.

  • eqn (str) – The str representation of the equation to use. This will be passed to sympy’s sympify function to make a live sympy object.

  • x (str) – The dictionary key of the independent variable

  • kwargs – All additional keyword arguments are converted to sympy variables using the symbols function. Note that IF the arguments are strs, it is assumed they are dictionary keys pointing to arrays on the target object. If they are numerical values they are used ‘as is’. Numpy arrays are not accepted. These must be stored in the target dictionary and referenced by key.


>>> import openpnm as op
>>> from openpnm.models.physics import generic_source_term as gst
>>> import numpy as np
>>> import sympy
>>> pn =[5, 5, 5], spacing=0.0001)
>>> water = op.phases.Water(network=pn)
>>> water['pore.a'] = 1
>>> water['pore.b'] = 2
>>> water['pore.c'] = 3
>>> water['pore.x'] = np.random.random(water.Np)
>>> y = 'a*x**b + c'
>>> arg_map = {'a':'pore.a', 'b':'pore.b', 'c':'pore.c'}
>>> water.add_model(propname='pore.general',
...                 model=gst.general_symbolic,
...                 eqn=y, x='pore.x', **arg_map)