Skip to content

Conversation

@schymans
Copy link
Collaborator

@schymans schymans commented Dec 22, 2022

In the current version, it is not possible to use symbolic functions in Equation(), e.g.:

from sympy import Derivative, Eq, Function, symbols
from essm.variables import Variable
from essm.equations import Equation
from essm.variables.units import meter, second

class v(Variable):
    """Velocity"""
    unit = meter / second

class d(Variable):
    """Distance"""
    unit = meter
    
class t(Variable):
    """Time"""
    unit = second

dt = Function(d)(t)    
class eq_v(Equation):
    """Average velocity as a function of time"""
    expr = Eq(v, Derivative(dt, t))

ValueError: Arguments in function are not dimensionless, but have dimensions of {Dimension(time)}

This PR disables the requirement that arguments in functions must be dimensionless.

@schymans
Copy link
Collaborator Author

Now the error is different:

dt = Function(d)(t)    
class eq_v(Equation):
    """Average velocity as a function of time"""
    expr = Eq(v, Derivative(dt, t))

ValueError: Dimension of "v" is Dimension(length/time), but it should be the same as Derivative(d(t), t), i.e. Dimension(1/time)
This is because the symbolic function dt did not inherit the units of d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant