Skip to content

Commit

Permalink
Better comments
Browse files Browse the repository at this point in the history
  • Loading branch information
wallytutor committed Oct 17, 2024
1 parent 19b51bd commit 0dd3f49
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/wallytoolbox/thermochemistry/acausal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,22 @@ struct AlgebraicModel
end

function structural_solve(obj::AlgebraicModel)
# Clean-up symbols that were provided by user.
eqns = replacement_solve(obj)

# Cannot solve if has parameters but DoF are not respected...
if has_pars(obj) && has_dofs(obj, eqns)
throw(UnsolvableAlgebraicModel(obj.vars, obj.pars))
end

# XXX: can we eliminate this, the system is already solved here...
@mtkbuild ns = NonlinearSystem(eqns, [values(obj.vars)...], [])
sol = solve(NonlinearProblem(ns, [], []))

# Get names (LHS of equations) to retrieve solution.
solved_for = map(e->e.lhs, observed(ns))

# Full-specification is found through parameters and variables.
pars = tuplefy(obj.pars)
vars = NamedTuple(map(n->(Symbol(n), sol[n]), solved_for))
return merge(pars, vars)
Expand Down

0 comments on commit 0dd3f49

Please sign in to comment.