Skip to content

Commit

Permalink
Add function to handle isoline data calculation for new iterator stru…
Browse files Browse the repository at this point in the history
…cture
  • Loading branch information
fwitte committed Jul 21, 2024
1 parent a9cbb0e commit 2577996
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/fluprodia/fluid_property_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,35 @@ def _single_isothermal(self, iterator, T):
else:
return self._insert_Q_crossings(datapoints, 'T', data)

def _single_isoline(self, iterators, isoline_property, isoline_value):
"""Calculate an isoline of constant temperature."""
datapoints = {'h': [], 'T': [], 'v': [], 's': [], 'p': [], 'Q': []}

num_points = sum([len(_[1]) for _ in iterators])
datapoints[isoline_property] = np.ones(num_points) * isoline_value
for iterator_property, iterator_values in iterators:
self.state.unspecify_phase()
datapoints[iterator_property] += iterator_values.tolist()

for value in iterator_values:
try:
self._update_state({isoline_property: isoline_value, iterator_property: value})
success = True
except ValueError as e:
success = False

result = np.nan
for result_property in set(datapoints.keys()) - {iterator_property, isoline_property}:
if success:
result = self._get_state_result_by_name(result_property)

datapoints[result_property] += [result]

for key in set(datapoints.keys()) - {isoline_property}:
datapoints[key] = np.asarray(datapoints[key])

return datapoints

def _single_isenthalpic(self, iterator, h):
"""Calculate an isoline of constant specific enthalpy."""
datapoints = {'h': [], 'T': [], 'v': [], 's': [], 'p': []}
Expand Down

0 comments on commit 2577996

Please sign in to comment.