Resolve "Saving and reading states"
Closes #41 (closed)
- result architecture is solved through composition, each result contains a ResultInfo object and an ExperimentConfig object
- every result is automatically saved, together with a report.json that fully describes the experiment, material, machine, etc. (such that it can be repeated based on that and possible mesh data)
- results are (almost completely) immutable and contain no mutable references
- each result can have a label that can be assigned when running the experiment, e.g. `eigenmodes(..., label="backward_volume")```
- added get_mode_local() to EigenResult
- added AbsorptionResult and PerturbationResult
- Perturbation is implemented (produces its own result) but does not store individual stiffness fields yet
Example
%matplotlib notebook
import matplotlib.pyplot as plt
from tetrax import Sample, geometries, experiments
layer = Sample(geometries.layer.monolayer(50,1), name="monolayer50nm")
layer.mag = (1, 0, 0)
Bext = 20e-3
layer.external_field = (Bext, 0, 0)
experiments.relax(layer)
interactions=[layer.get_interaction(name) for name in ["zeemann", "exchange"]]
exchange_spectrum = experiments.eigenmodes(layer, num_cpus=-1, interactions=interactions, label="exchange")
perturbed_spectrum = exchange_spectrum.perturb_with(layer.get_interaction("dipole"), label="dipole")
exact_spectrum = experiments.eigenmodes(layer, num_cpus=-1, label="exact")
fig, ax = plt.subplots()
for i in range(2):
plt.plot(perturbed_spectrum.k,perturbed_spectrum.frequencies(i), ls="--")
plt.plot(perturbed_spectrum.k,exact_spectrum.frequencies(i))
produces
And the directory looks like
monolayer50nm/
eigen_exact
external_field.vtk
eigenvalue_dataframe.csv
mode_profiles
...
equilibrium.vtk
report.json
eigen_exchange
eigenvalue_dataframe.csv
mode_profiles
...
equilibrium.vtk
perturbation_dipole
perturbed_frequency_dataframe.csv
report.json
external_field.vtk
report.json
references.bib
relax
energy_mag_log.csv
final_state.vtk
report.json
external_field.vtk
initial_state.vtk
for example, eigen_exchange/report.json
looks like
{
"result_type": "eigen",
"config": {
"km_limits": [
null,
-40000000.0,
40000000.0,
81,
null,
-5,
5
],
"save_modes": true,
"optional_output": [],
"parallel_backend": "loky",
"num_cpus": 8,
"frequency_tolerance": 0.001,
"inverse_tolerance": 0.0001,
"maxiter_inverse": 1000,
"interactions": [
"zeemann",
"exchange"
],
"_comment": "Toothless interactions (with relevant material parameters equal zero) are marked with '*'."
},
"outcome": {
"has_profiles": true,
"has_linewidths": false,
"k (rad/m)": "-40000000.0, -39000000.0, ..., 39000000.0, 40000000.0",
"m": "0.0",
"modes_per_km": 20,
"files": [
"external_field.vtk",
"equilibrium.vtk",
"eigenvalue_dataframe.csv",
"mode_profiles/"
]
},
"result_info": {
"type": "eigen",
"label": "exchange",
"path": "monolayer50nm/eigen_exchange",
"created": "2024-03-31T16:08:20.234266",
"environment": {
"tetrax_version": "2.0.0dev0",
"platform": "Darwin",
"cpu": "Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz"
},
"sample_snapshot": {
"name": "monolayer50nm",
"geometry_type": "layer",
"magnetic_order": "FM",
"material": {
"Msat": 796000.0,
"Aex": 1.3e-11,
"gamma": 176085964400.0,
"alpha": 0.008,
"Ku1": 0,
"e_u": [
0.0,
0.0,
1.0
],
"Dbulk": 0,
"Didmi": 0,
"e_d": [
0.0,
1.0,
0.0
],
"Kc1": 0,
"e_c1": [
1.0,
0.0,
0.0
],
"e_c2": [
0.0,
1.0,
0.0
]
}
}
}
}
Edited by Koerber, Lukas (FWIN-C) - 108045