general_symbolic(phase, eqn, x, **kwargs)[source]#

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

  • phase (OpenPNM Phase object) – The phase object to which this model is associated (i.e. attached). This controls the length of the calculated array(s), 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 phase object. If they are numerical values they are used ‘as is’. Numpy arrays are not accepted. These must be stored in the phase dictionary and referenced by key.


>>> import openpnm as op
>>> from openpnm.models.physics import source_terms as st
>>> import numpy as np
>>> import sympy
>>> pn =[5, 5, 5], spacing=0.0001)
>>> water = op.phase.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=st.general_symbolic,
...                 eqn=y, x='pore.x', **arg_map)