Skip to content

Commit 917bde3

Browse files
authored
Merge branch 'paper' into profiles
2 parents 20d06f2 + 090a896 commit 917bde3

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

examples/sparging_standard.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
dispersion_on=True,
4040
constant_profiles=False,
4141
)
42+
43+
standard_input.to_json(FOLDER / "intermediate_params.json")
44+
breakpoint()
4245
if __name__ == "__main__":
4346
my_simulation.exports = ["P_g", "a", "aJ_T2"]
4447
output = my_simulation.solve(fast_solve=True)

src/sparging/inputs.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22
from dataclasses import dataclass, replace
3+
from datetime import datetime
4+
from sparging import helpers
35
from sparging.correlations import Correlation, all_correlations
46
import pint
57
from typing import List
@@ -220,15 +222,29 @@ def __post_init__(self):
220222
def to_json(self, path: str):
221223
import json
222224

225+
output = {
226+
"metadata": {
227+
"git_commit": helpers.get_git_hash(),
228+
"date": datetime.now().isoformat(),
229+
},
230+
}
231+
232+
output["intermediate parameters"] = {}
233+
for node in self.graph.nodes:
234+
output["intermediate parameters"][node] = {
235+
"value": str(self.graph.nodes[node]["value"]),
236+
"origin": self.graph.nodes[node]["origin"],
237+
}
223238
with open(path, "w") as f:
224239
json.dump(
225-
{
226-
key: str(value)
227-
for key, value in self.__dict__.items()
228-
if isinstance(value, pint.Quantity)
229-
},
240+
output,
241+
# {
242+
# key: str(value)
243+
# for key, value in self.__dict__.items()
244+
# if isinstance(value, pint.Quantity)
245+
# },
230246
f,
231-
indent=2,
247+
indent=4,
232248
)
233249

234250
@classmethod

0 commit comments

Comments
 (0)