Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conditions: Improve robustness of derivative parsing #29

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
conditions: Improve robustness of derivative parsing
  • Loading branch information
EdCaunt committed Apr 19, 2024
commit 4e8776a643076a7052d49e391c2d78e0b4d7387e
18 changes: 12 additions & 6 deletions schism/conditions/boundary_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,19 @@ def sub_basis(self, basis_map):
except KeyError:
# Should never end up here
raise ValueError("No basis generated for required function")
if type(deriv.deriv_order) != dv.types.utils.DimensionTuple:
d_o = (deriv.deriv_order,)

if type(deriv.deriv_order) is int:
# Derivative taken wrt single dimension.
b_derivs = [(deriv.dims[0], deriv.deriv_order)]
else:
d_o = deriv.deriv_order
# Derivs to take of the basis
b_derivs = tuple([(deriv.dims[i], d_o[i])
for i in range(len(deriv.dims))])
d_order = tuple(o for o in deriv.deriv_order if o != 0)
if len(deriv.dims) != len(d_order):
raise ValueError("Derivatives specified as"
" Derivative(f, x, x) are not compatible"
" with Schism. Use the"
" Derivative(f, (x, 2)) or f.dx2"
" conventions instead")
b_derivs = [(d, o) for d, o in zip(deriv.dims, d_order)]
reps[deriv] = basis.deriv(b_derivs)
return sp.simplify(self._mod_lhs.subs(reps))

Expand Down
Loading