Skip to content

Commit

Permalink
Only apply the newton method for mixtures
Browse files Browse the repository at this point in the history
Use the default method normally
  • Loading branch information
ibell committed Oct 4, 2023
1 parent 1a334e4 commit 710b861
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions PDSim/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,11 +1264,16 @@ def OBJECTIVE_CYCLE(self, Td_Tlumps0, X, epsilon_cycle = 0.003, epsilon_energy_b
# value for it
h_target = hdnew

# Iterate to solve the H, P flash calculation
def objective(T):
self.Tubes.Nodes[self.key_outlet].update(dict(T=T, P=self.Tubes.Nodes[self.key_outlet].p))
return self.Tubes.Nodes[self.key_outlet].h - h_target
scipy.optimize.newton(objective, self.Tubes.Nodes[self.key_outlet].T)
if hasattr(self.Tubes.Nodes[self.key_outlet],'pAS') and len(self.Tubes.Nodes[self.key_outlet].pAS.fluid_names()) == 1:
self.Tubes.Nodes[self.key_outlet].update_ph(self.Tubes.Nodes[self.key_outlet].p, h_target)
else:
# Iterate to solve the H, P flash calculation
def objective(T):
self.Tubes.Nodes[self.key_outlet].update(dict(T=T, P=self.Tubes.Nodes[self.key_outlet].p))
residual = self.Tubes.Nodes[self.key_outlet].h - h_target
print(T, residual)
return residual
scipy.optimize.newton(objective, self.Tubes.Nodes[self.key_outlet].T)

print(self.solvers.hdisc_history)

Expand Down

0 comments on commit 710b861

Please sign in to comment.