Closed schymans closed 5 years ago
Here is a more complete example:
from essm.variables import Variable
from essm.equations import Equation
from sympy.physics.units import meter, second
from sympy import Eq, S
class l1(Variable):
"""Length"""
unit = meter
class l2(Variable):
"""Length"""
unit = meter
class g(Variable):
"""Graviational acceleration"""
unit = meter / second ** 2
default = 9.8
class t1(Variable):
"""Time"""
unit = second
class v1(Variable):
"""Velocity"""
unit = meter / second
class eq_fall(Equation):
"""Distance of fall."""
expr = Eq(l1, S(1) / S(2) * g * t1 ** 2)
print eq_fall
print eq_fall.subs(l1, l2)
returns:
Eq(l1, g*t1**2/2)
g*t1**2/2
This does not happen for sympy Eq():
eq_fall = Eq(l1, S(1) / S(2) * g * t1 ** 2)
print eq_fall
returns:
Eq(l1, g*t1**2/2)
Eq(l2, g*t1**2/2)
PR #47 solved this issue.
Substitution into an equation drops the left-hand-side of the equation, and only returns the right hand side:
returns
It should return instead: