Skip to content

Commit

Permalink
sympy consistency and add theta_i to AxionEffectiveFluid.set_params (#77
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cmbant committed May 15, 2020
1 parent 963ea43 commit c9ea899
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion camb/dark_energy.py
Expand Up @@ -111,10 +111,12 @@ class AxionEffectiveFluid(DarkEnergyModel):
_fortran_class_name_ = 'TAxionEffectiveFluid'
_fortran_class_module_ = 'DarkEnergyFluid'

def set_params(self, w_n, om, a_c):
def set_params(self, w_n, om, a_c, theta_i=None):
self.w_n = w_n
self.om = om
self.a_c = a_c
if theta_i is not None:
self.theta_i = theta_i


# short names for models that support w/wa
Expand Down
8 changes: 4 additions & 4 deletions camb/symbolic.py
Expand Up @@ -56,20 +56,20 @@

def subs(eqs, expr):
# generalization to act on lists of equations, and support using Eq equations.
# lists are substituted irrespective of order, so no RHS variables are substituted by other elements
# lists and dicts are substituted irrespective of order, so no RHS variables
# are substituted by other elements
if isinstance(expr, (list, tuple)):
res = [subs(eqs, ex) for ex in expr]
return [x for x in res if x is not True]
if not isinstance(expr, (sympy.Expr, Relational)):
return expr
if isinstance(eqs, dict):
return expr.subs(eqs)
return expr.subs(eqs, simultaneous=True)
else:
if not isinstance(eqs, (list, tuple)):
return expr.subs(eqs.lhs, eqs.rhs)
eqs = [(eq.lhs, eq.rhs) for eq in eqs]
# must use dict in order for rhs not to be substituted by subsequent lhs
return expr.subs(dict(eqs), simultaneous=True)
return expr.subs(eqs, simultaneous=True)


def solve(eq, x):
Expand Down

0 comments on commit c9ea899

Please sign in to comment.