|
39 | 39 |
|
40 | 40 |
|
41 | 41 | @dataclass |
42 | | -class SimulationResults: # TODO implement pint in this class # TODO change list to np.array |
43 | | - times: list |
44 | | - c_T2_solutions: list |
45 | | - y_T2_solutions: list |
46 | | - J_T2_solutions: list |
47 | | - x_ct: np.ndarray |
48 | | - x_y: np.ndarray |
49 | | - inventories_T2_salt: np.ndarray |
50 | | - sources_T2: list |
51 | | - fluxes_T2: list |
| 42 | +class SimulationResults: |
| 43 | + times: np.ndarray[pint.Quantity] |
| 44 | + c_T2_solutions: np.ndarray[pint.Quantity] |
| 45 | + y_T2_solutions: np.ndarray[pint.Quantity] |
| 46 | + J_T2_solutions: np.ndarray[pint.Quantity] |
| 47 | + x_ct: np.ndarray[pint.Quantity] |
| 48 | + x_y: np.ndarray[pint.Quantity] |
| 49 | + inventories_T2_salt: np.ndarray[pint.Quantity] |
| 50 | + sources_T2: np.ndarray[pint.Quantity] |
| 51 | + fluxes_T2: np.ndarray[pint.Quantity] |
52 | 52 | sim_input: SimulationInput |
53 | | - dt: int | None = None |
54 | | - dx: int | None = None |
| 53 | + dt: pint.Quantity |
| 54 | + dx: pint.Quantity |
55 | 55 |
|
56 | 56 | keys_to_ignore_results = [ # TODO do it the other way: keys_to_include_results |
57 | 57 | "c_T2_solutions", |
@@ -428,22 +428,20 @@ def post_process(t): |
428 | 428 | # advance time |
429 | 429 | t += dt |
430 | 430 |
|
431 | | - inventories_T2_salt = np.array(inventories_T2_salt) |
432 | | - |
433 | 431 | # TODO reattach units using wrapping |
434 | 432 | # https://pint.readthedocs.io/en/stable/advanced/performance.html#a-safer-method-wrapping |
435 | 433 | results = SimulationResults( |
436 | | - times=times, |
437 | | - c_T2_solutions=c_T2_solutions, |
438 | | - y_T2_solutions=y_T2_solutions, |
439 | | - J_T2_solutions=J_T2_solutions, |
440 | | - x_ct=x_ct, |
441 | | - x_y=x_y, |
442 | | - inventories_T2_salt=inventories_T2_salt, |
443 | | - sources_T2=sources_T2, |
444 | | - fluxes_T2=fluxes_T2, |
| 434 | + times=np.array(times) * ureg("s"), |
| 435 | + c_T2_solutions=np.array(c_T2_solutions) * ureg("molT2/m^3"), |
| 436 | + y_T2_solutions=np.array(y_T2_solutions) * ureg("dimensionless"), |
| 437 | + J_T2_solutions=np.array(J_T2_solutions) * ureg("molT2/m^3/s"), |
| 438 | + x_ct=x_ct * ureg("m"), |
| 439 | + x_y=x_y * ureg("m"), |
| 440 | + inventories_T2_salt=np.array(inventories_T2_salt) * ureg("molT2"), |
| 441 | + sources_T2=np.array(sources_T2) * ureg("molT2/s"), |
| 442 | + fluxes_T2=np.array(fluxes_T2) * ureg("molT2/s"), |
445 | 443 | sim_input=self.sim_input, |
446 | | - dt=dt, |
447 | | - dx=dx, |
| 444 | + dt=dt * ureg("s"), |
| 445 | + dx=dx * ureg("m"), |
448 | 446 | ) |
449 | 447 | return results |
0 commit comments