llg3d 1.4.1__py3-none-any.whl → 2.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
llg3d/__init__.py CHANGED
@@ -1 +1,6 @@
1
- __version__ = "1.4.1"
1
+ """Main llg3d package."""
2
+
3
+ from .solver import LIB_AVAILABLE, rank, size, comm, status
4
+
5
+ __version__ = "2.0.1"
6
+ __all__ = ["LIB_AVAILABLE", "rank", "size", "comm", "status", "__version__"]
llg3d/__main__.py ADDED
@@ -0,0 +1,6 @@
1
+ """Main entry point to execute the llg3d module."""
2
+
3
+ from .main import main
4
+
5
+ if __name__ == "__main__":
6
+ main()
llg3d/element.py ADDED
@@ -0,0 +1,134 @@
1
+ """Module containing the definition of the chemical elements."""
2
+
3
+ from abc import ABC
4
+
5
+ import numpy as np
6
+
7
+ from .grid import Grid
8
+
9
+ k_B = 1.38e-23 #: Boltzmann constant :math:`[J.K^{-1}]`
10
+ mu_0 = 4 * np.pi * 1.0e-7 #: Vacuum permeability :math:`[H.m^{-1}]`
11
+ gamma = 1.76e11 #: Gyromagnetic ratio :math:`[rad.s^{-1}.T^{-1}]`
12
+
13
+
14
+ class Element(ABC):
15
+ """
16
+ Abstract class for chemical elements.
17
+
18
+ Args:
19
+ T: Temperature in Kelvin
20
+ H_ext: External magnetic field strength
21
+ g: Grid object representing the simulation grid
22
+ dt: Time step for the simulation
23
+ """
24
+
25
+ A = 0.0
26
+ K = 0.0
27
+ lambda_G = 0.0
28
+ M_s = 0.0
29
+ a_eff = 0.0
30
+ anisotropy: str = ""
31
+
32
+ def __init__(self, T: float, H_ext: float, g: Grid, dt: float) -> None:
33
+ self.H_ext = H_ext
34
+ self.g = g
35
+ self.dt = dt
36
+ self.gamma_0 = gamma * mu_0 #: Rescaled gyromagnetic ratio [mA^-1.s^-1]
37
+
38
+ # --- Characteristic Scales ---
39
+ self.coeff_1 = self.gamma_0 * 2.0 * self.A / (mu_0 * self.M_s)
40
+ self.coeff_2 = self.gamma_0 * 2.0 * self.K / (mu_0 * self.M_s)
41
+ self.coeff_3 = self.gamma_0 * H_ext
42
+
43
+ # corresponds to the temperature actually put into the random field
44
+ T_simu = T * self.g.dx / self.a_eff
45
+ # calculation of the random field related to temperature
46
+ # (we only take the volume over one mesh)
47
+ h_alea = np.sqrt(
48
+ 2 * self.lambda_G * k_B / (self.gamma_0 * mu_0 * self.M_s * self.g.dV)
49
+ )
50
+ H_alea = h_alea * np.sqrt(T_simu) * np.sqrt(1.0 / self.dt)
51
+ self.coeff_4 = H_alea * self.gamma_0
52
+
53
+ def get_CFL(self) -> float:
54
+ """
55
+ Returns the value of the CFL.
56
+
57
+ Returns:
58
+ The CFL value
59
+ """
60
+ return self.dt * self.coeff_1 / self.g.dx**2
61
+
62
+ def to_dict(self) -> dict:
63
+ """
64
+ Export element parameters to a dictionary for JAX JIT compatibility.
65
+
66
+ Returns:
67
+ Dictionary containing element parameters needed for computations
68
+ """
69
+ # Map anisotropy string to integer for JIT compatibility
70
+ aniso_map = {"uniaxial": 0, "cubic": 1}
71
+
72
+ return {
73
+ "coeff_1": self.coeff_1,
74
+ "coeff_2": self.coeff_2,
75
+ "coeff_3": self.coeff_3,
76
+ "coeff_4": self.coeff_4,
77
+ "lambda_G": self.lambda_G,
78
+ "anisotropy": aniso_map[self.anisotropy],
79
+ "gamma_0": self.gamma_0,
80
+ }
81
+
82
+
83
+ class Cobalt(Element):
84
+ """Cobalt element."""
85
+
86
+ A = 30.0e-12 #: Exchange constant :math:`[J.m^{-1}]`
87
+ K = 520.0e3 #: Anisotropy constant :math:`[J.m^{-3}]`
88
+ lambda_G = 0.5 #: Damping parameter :math:`[1]`
89
+ M_s = 1400.0e3 #: Saturation magnetization :math:`[A.m^{-1}]`
90
+ a_eff = 0.25e-9 #: Effective lattice constant :math:`[m]`
91
+ anisotropy = "uniaxial" #: Type of anisotropy (e.g., "uniaxial", "cubic")
92
+
93
+
94
+ class Iron(Element):
95
+ """Iron element."""
96
+
97
+ A = 21.0e-12 #: Exchange constant :math:`[J.m^{-1}]`
98
+ K = 48.0e3 #: Anisotropy constant :math:`[J.m^{-3}]`
99
+ lambda_G = 0.5 #: Damping parameter :math:`[1]`
100
+ M_s = 1700.0e3 #: Saturation magnetization :math:`[A.m^{-1}]`
101
+ a_eff = 0.286e-9 #: Effective lattice constant :math:`[m]`
102
+ anisotropy = "cubic" #: Type of anisotropy (e.g., "uniaxial", "cubic")
103
+
104
+
105
+ class Nickel(Element):
106
+ """Nickel element."""
107
+
108
+ A = 9.0e-12 #: Exchange constant :math:`[J.m^{-1}]`
109
+ K = -5.7e3 #: Anisotropy constant :math:`[J.m^{-3}]`
110
+ lambda_G = 0.5 #: Damping parameter :math:`[1]`
111
+ M_s = 490.0e3 #: Saturation magnetization :math:`[A.m^{-1}]`
112
+ a_eff = 0.345e-9 #: Effective lattice constant :math:`[m]`
113
+ anisotropy = "cubic" #: Type of anisotropy (e.g., "uniaxial", "cubic")
114
+
115
+
116
+ def get_element_class(element_name: str | type[Element]) -> type[Element]:
117
+ """
118
+ Get the class of the chemical element by its name.
119
+
120
+ Args:
121
+ element_name: The name of the element or its class
122
+
123
+ Returns:
124
+ The class of the element
125
+
126
+ Raises:
127
+ ValueError: If the element is not found
128
+ """
129
+ if isinstance(element_name, type):
130
+ return element_name
131
+ for cls in Element.__subclasses__():
132
+ if cls.__name__ == element_name:
133
+ return cls
134
+ raise ValueError(f"Element '{element_name}' not found in {__file__}.")
llg3d/grid.py ADDED
@@ -0,0 +1,123 @@
1
+ """Module to define the grid for the simulation."""
2
+
3
+ from dataclasses import dataclass
4
+ import numpy as np
5
+
6
+ from .solver import rank, size
7
+
8
+
9
+ @dataclass
10
+ class Grid:
11
+ """Stores grid data."""
12
+
13
+ # Parameter values correspond to the global grid
14
+ Jx: int #: number of points in x direction
15
+ Jy: int #: number of points in y direction
16
+ Jz: int #: number of points in z direction
17
+ dx: float #: grid spacing in x direction
18
+
19
+ def __post_init__(self) -> None:
20
+ """Compute grid characteristics."""
21
+ self.dy = self.dz = self.dx # Setting dx = dy = dz
22
+ self.Lx = (self.Jx - 1) * self.dx
23
+ self.Ly = (self.Jy - 1) * self.dy
24
+ self.Lz = (self.Jz - 1) * self.dz
25
+ # shape of the local array to the process
26
+ self.dims = self.Jx // size, self.Jy, self.Jz
27
+ # elemental volume of a cell
28
+ self.dV = self.dx * self.dy * self.dz
29
+ # total volume
30
+ self.V = self.Lx * self.Ly * self.Lz
31
+ # total number of points
32
+ self.ntot = self.Jx * self.Jy * self.Jz
33
+ self.ncell = (self.Jx - 1) * (self.Jy - 1) * (self.Jz - 1)
34
+
35
+ def __str__(self) -> str:
36
+ """Print grid information."""
37
+ header = "\t\t".join(("x", "y", "z"))
38
+ s = f"""\
39
+ \t{header}
40
+ J\t{self.Jx}\t\t{self.Jy}\t\t{self.Jz}
41
+ L\t{self.Lx:.08e}\t{self.Ly:.08e}\t{self.Lz:.08e}
42
+ d\t{self.dx:.08e}\t{self.dy:.08e}\t{self.dz:.08e}
43
+
44
+ dV = {self.dV:.08e}
45
+ V = {self.V:.08e}
46
+ ntot = {self.ntot:d}
47
+ ncell = {self.ncell:d}
48
+ """
49
+ return s
50
+
51
+ def get_filename(
52
+ self, T: float, name: str = "m1_mean", extension: str = "txt"
53
+ ) -> str:
54
+ """
55
+ Returns the output file name for a given temperature.
56
+
57
+ Args:
58
+ T: temperature
59
+ name: file name
60
+ extension: file extension
61
+
62
+ Returns:
63
+ file name
64
+
65
+ >>> g = Grid(Jx=300, Jy=21, Jz=21, dx=1.e-9)
66
+ >>> g.get_filename(1100)
67
+ 'm1_mean_T1100_300x21x21.txt'
68
+ """
69
+ suffix = f"T{int(T)}_{self.Jx}x{self.Jy}x{self.Jz}"
70
+ return f"{name}_{suffix}.{extension}"
71
+
72
+ def get_mesh(
73
+ self, local: bool = True, dtype=np.float64
74
+ ) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
75
+ """
76
+ Returns a meshgrid of the coordinates.
77
+
78
+ Args:
79
+ local: if True, returns the local coordinates,
80
+ otherwise the global coordinates
81
+ dtype: data type of the coordinates)
82
+
83
+ Returns:
84
+ tuple of 3D arrays with the coordinates
85
+ """
86
+ x_global = np.linspace(0, self.Lx, self.Jx, dtype=dtype) # global coordinates
87
+ y = np.linspace(0, self.Ly, self.Jy, dtype=dtype)
88
+ z = np.linspace(0, self.Lz, self.Jz, dtype=dtype)
89
+ if local:
90
+ x_local = np.split(x_global, size)[rank] # local coordinates
91
+ return np.meshgrid(x_local, y, z, indexing="ij")
92
+ else:
93
+ return np.meshgrid(x_global, y, z, indexing="ij")
94
+
95
+ def to_dict(self) -> dict:
96
+ """
97
+ Export grid parameters to a dictionary for JAX JIT compatibility.
98
+
99
+ Returns:
100
+ Dictionary containing grid parameters needed for computations
101
+ """
102
+ return {
103
+ "dx": self.dx,
104
+ "dy": self.dy,
105
+ "dz": self.dz,
106
+ "Jx": self.Jx,
107
+ "Jy": self.Jy,
108
+ "Jz": self.Jz,
109
+ "dV": self.dV,
110
+ }
111
+
112
+ def get_laplacian_coeff(self) -> tuple[float, float, float, float]:
113
+ """
114
+ Returns the coefficients for the laplacian computation.
115
+
116
+ Returns:
117
+ Tuple of coefficients (dx2_inv, dy2_inv, dz2_inv, center_coeff)
118
+ """
119
+ dx2_inv = 1 / self.dx**2
120
+ dy2_inv = 1 / self.dy**2
121
+ dz2_inv = 1 / self.dz**2
122
+ center_coeff = -2 * (dx2_inv + dy2_inv + dz2_inv)
123
+ return dx2_inv, dy2_inv, dz2_inv, center_coeff
llg3d/main.py ADDED
@@ -0,0 +1,67 @@
1
+ """Define a CLI for the llg3d package."""
2
+
3
+ import argparse
4
+
5
+
6
+ from . import rank, size, LIB_AVAILABLE
7
+ from .parameters import parameters, get_parameter_list
8
+ from .simulation import Simulation
9
+
10
+ if LIB_AVAILABLE["mpi4py"]:
11
+ # Use the MPI version of the ArgumentParser
12
+ from .solver.mpi import ArgumentParser
13
+ else:
14
+ # Use the original version of the ArgumentParser
15
+ from argparse import ArgumentParser
16
+
17
+
18
+ def parse_args(args: list[str] | None) -> argparse.Namespace:
19
+ """
20
+ Argument parser for llg3d.
21
+
22
+ Automatically adds arguments from the parameter dictionary.
23
+
24
+ Returns:
25
+ argparse.Namespace: Parsed arguments
26
+ """
27
+ parser = ArgumentParser(
28
+ description=__doc__,
29
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
30
+ )
31
+
32
+ if size > 1:
33
+ parameters["solver"]["default"] = "mpi"
34
+
35
+ # Automatically add arguments from the parameter dictionary
36
+ for name, parameter in parameters.items():
37
+ if "action" not in parameter:
38
+ parameter["type"] = type(parameter["default"])
39
+ parser.add_argument(f"--{name}", **parameter)
40
+
41
+ return parser.parse_args(args)
42
+
43
+
44
+ def main(arg_list: list[str] = None):
45
+ """
46
+ Evaluates the command line and runs the simulation.
47
+
48
+ Args:
49
+ arg_list: List of command line arguments
50
+ """
51
+ args = parse_args(arg_list)
52
+
53
+ if size > 1 and args.solver != "mpi":
54
+ raise ValueError(f"Solver method {args.solver} is not compatible with MPI.")
55
+ if args.solver == "mpi" and not LIB_AVAILABLE["mpi4py"]:
56
+ raise ValueError(
57
+ "The MPI solver method requires to install the mpi4py package, "
58
+ "for example using pip: pip install mpi4py"
59
+ )
60
+
61
+ if rank == 0:
62
+ # Display parameters as a list
63
+ print(get_parameter_list(vars(args)))
64
+
65
+ simulation = Simulation(vars(args))
66
+ simulation.run()
67
+ simulation.save()
llg3d/output.py ADDED
@@ -0,0 +1,107 @@
1
+ """Utility functions for LLG3D."""
2
+
3
+ import json
4
+ import sys
5
+ from typing import Iterable, TextIO
6
+
7
+ from .solver import rank
8
+ from .grid import Grid
9
+
10
+
11
+ def progress_bar(
12
+ it: Iterable, prefix: str = "", size: int = 60, out: TextIO = sys.stdout
13
+ ):
14
+ """
15
+ Displays a progress bar.
16
+
17
+ (Source: https://stackoverflow.com/a/34482761/16593179)
18
+
19
+ Args:
20
+ it: Iterable object to iterate over
21
+ prefix: Prefix string for the progress bar
22
+ size: Size of the progress bar (number of characters)
23
+ out: Output stream (default is sys.stdout)
24
+ """
25
+ count = len(it)
26
+
27
+ def show(j):
28
+ x = int(size * j / count)
29
+ if rank == 0:
30
+ print(
31
+ f"{prefix}[{'█' * x}{('.' * (size - x))}] {j}/{count}",
32
+ end="\r",
33
+ file=out,
34
+ flush=True,
35
+ )
36
+
37
+ show(0)
38
+ for i, item in enumerate(it):
39
+ yield item
40
+ # To avoid slowing down the computation, we do not display at every iteration
41
+ if i % 5 == 0:
42
+ show(i + 1)
43
+ show(i + 1)
44
+ if rank == 0:
45
+ print("\n", flush=True, file=out)
46
+
47
+
48
+ def write_json(json_file: str, run: dict):
49
+ """
50
+ Writes the run dictionary to a JSON file.
51
+
52
+ Args:
53
+ json_file: Name of the JSON file
54
+ run: Dictionary containing the run information
55
+ """
56
+ with open(json_file, "w") as f:
57
+ json.dump(run, f, indent=4)
58
+
59
+
60
+ def get_output_files(g: Grid, T: float, n_mean: int, n_profile: int) -> tuple:
61
+ """
62
+ Open files and list them.
63
+
64
+ Args:
65
+ g: Grid object
66
+ T: temperature
67
+ n_mean: Number of iterations for integral output
68
+ n_profile: Number of iterations for profile output
69
+
70
+ Returns:
71
+ - a file handler for storing m space integral over time
72
+ - a file handler for storing x-profiles of m_i
73
+ - a list of output filenames
74
+ """
75
+ f_mean = None
76
+ f_profiles = None
77
+ output_filenames = []
78
+ if n_mean != 0:
79
+ output_filenames.append(g.get_filename(T, extension="txt"))
80
+ if n_profile != 0:
81
+ output_filenames.extend(
82
+ [g.get_filename(T, name=f"m{i + 1}", extension="npy") for i in range(3)]
83
+ )
84
+ if rank == 0:
85
+ if n_mean != 0:
86
+ f_mean = open(output_filenames[0], "w") # integral of m1
87
+ if n_profile != 0:
88
+ f_profiles = [
89
+ open(output_filename, "wb") for output_filename in output_filenames[1:]
90
+ ] # x profiles of m_i
91
+
92
+ return f_mean, f_profiles, output_filenames
93
+
94
+
95
+ def close_output_files(f_mean: TextIO, f_profiles: list[TextIO] = None):
96
+ """
97
+ Close all output files.
98
+
99
+ Args:
100
+ f_mean: file handler for storing m space integral over time
101
+ f_profiles: file handlers for storing x-profiles of m_i
102
+ """
103
+ if f_mean is not None:
104
+ f_mean.close()
105
+ if f_profiles is not None:
106
+ for f_profile in f_profiles:
107
+ f_profile.close()
llg3d/parameters.py ADDED
@@ -0,0 +1,75 @@
1
+ """Parameters for the LLG3D simulation."""
2
+
3
+ import numpy as np
4
+
5
+ # Parameters: default value and description
6
+ Parameter = dict[str, str | int | float | bool] #: Type for a parameter
7
+
8
+ parameters: dict[str, Parameter] = {
9
+ "element": {
10
+ "help": "Chemical element of the sample",
11
+ "default": "Cobalt",
12
+ "choices": ["Cobalt", "Iron", "Nickel"],
13
+ },
14
+ "N": {"help": "Number of time iterations", "default": 5000},
15
+ "dt": {"help": "Time step", "default": 1.0e-14},
16
+ "Jx": {"help": "Number of points in x", "default": 300},
17
+ "Jy": {"help": "Number of points in y", "default": 21},
18
+ "Jz": {"help": "Number of points in z", "default": 21},
19
+ "dx": {"help": "Step in x", "default": 1.0e-9},
20
+ "T": {"help": "Temperature (K)", "default": 0.0},
21
+ "H_ext": {"help": "External field (A/m)", "default": 0.0 / (4 * np.pi * 1.0e-7)},
22
+ "start_averaging": {"help": "Start index of time average", "default": 4000},
23
+ "n_mean": {
24
+ "help": "Spatial average frequency (number of iterations)",
25
+ "default": 1,
26
+ },
27
+ "n_profile": {
28
+ "help": "x-profile save frequency (number of iterations)",
29
+ "default": 0,
30
+ },
31
+ "solver": {
32
+ "help": "Solver to use for the simulation",
33
+ "default": "numpy",
34
+ "choices": ["opencl", "mpi", "numpy", "jax"],
35
+ },
36
+ "precision": {
37
+ "help": "Precision of the simulation (single or double)",
38
+ "default": "double",
39
+ "choices": ["single", "double"],
40
+ },
41
+ "blocking": {
42
+ "help": "Use blocking communications",
43
+ "default": False,
44
+ "action": "store_true",
45
+ },
46
+ "seed": {
47
+ "help": "Random seed for temperature fluctuations",
48
+ "default": 12345,
49
+ "type": int,
50
+ },
51
+ "device": {
52
+ "help": "Device to use ('cpu', 'gpu', or 'auto')",
53
+ "default": "auto",
54
+ "type": str,
55
+ },
56
+ } #: simulation parameters
57
+
58
+
59
+ def get_parameter_list(parameters: dict) -> str:
60
+ """
61
+ Returns parameter values as a string.
62
+
63
+ Args:
64
+ parameters: Dictionary of parameters parsed by argparse
65
+
66
+ Returns:
67
+ Formatted string of parameters
68
+ """
69
+ width = max([len(name) for name in parameters])
70
+ s = ""
71
+ for name, value in parameters.items():
72
+ # the seprator is ":" for strings and "=" for others
73
+ sep = ":" if isinstance(value, str) else "="
74
+ s += "{0:<{1}} {2} {3}\n".format(name, width, sep, value)
75
+ return s
llg3d/post/__init__.py CHANGED
@@ -1 +1 @@
1
- """Post-processing tools for LLG3D."""
1
+ """Post-processing tools for LLG3D."""
@@ -0,0 +1,61 @@
1
+ """
2
+ Plot 1D curves from several files.
3
+
4
+ Usage:
5
+
6
+ python plot_results.py file1.txt
7
+ or
8
+ python plot_results.py file1.txt file2.txt file3.txt
9
+
10
+ """
11
+
12
+ import argparse
13
+ from matplotlib import pyplot as plt
14
+ import numpy as np
15
+
16
+
17
+ DEFAULT_OUTPUT_FILE = "results.png"
18
+
19
+
20
+ def plot(*files: tuple[str], output_file: str = DEFAULT_OUTPUT_FILE):
21
+ """
22
+ Plot the results from the given files.
23
+
24
+ Args:
25
+ files (tuple[str]): Paths to the result files.
26
+ output_file (str): Path to the output image file.
27
+ """
28
+ fig, ax = plt.subplots()
29
+ for file in files:
30
+ if not file.endswith(".txt"):
31
+ raise ValueError(f"File {file} does not end with .txt")
32
+ data = np.loadtxt(file)
33
+ ax.plot(data[:, 0], data[:, 1], label=file)
34
+
35
+ ax.set_xlabel("time")
36
+ ax.set_ylabel(r"$<m_1>$")
37
+ ax.legend()
38
+ ax.set_title(r"Space average of $m_1$ according to time")
39
+ fig.savefig(output_file)
40
+ print(f"Written to {output_file}")
41
+ plt.show()
42
+
43
+
44
+ def main():
45
+ """Main function to parse arguments and call the plot function."""
46
+ parser = argparse.ArgumentParser(description="Plot results from one or more files.")
47
+ parser.add_argument("files", nargs="+", type=str, help="Path to the result files.")
48
+ parser.add_argument(
49
+ "--output",
50
+ "-o",
51
+ type=str,
52
+ default=DEFAULT_OUTPUT_FILE,
53
+ help=f"Path to the output image file (default: {DEFAULT_OUTPUT_FILE}).",
54
+ )
55
+ args = parser.parse_args()
56
+
57
+ plot(*args.files, output_file=args.output)
58
+
59
+
60
+ if __name__ == "__main__":
61
+ main()
llg3d/post/process.py CHANGED
@@ -1,12 +1,14 @@
1
1
  #!/usr/bin/env python3
2
2
  """
3
- Post-processes a set of runs grouped into a `run.json` file or
4
- into a set of SLURM job arrays:
3
+ Post-processes a set of runs.
4
+
5
+ Runs are grouped into a `run.json` file or into a set of SLURM job arrays:
5
6
 
6
7
  1. Extracts result data,
7
8
  2. Plots the computed average magnetization against temperature,
8
9
  3. Interpolates the computed points using cubic splines,
9
- 4. Determines the Curie temperature as the value corresponding to the minimal (negative) slope of the interpolated curve.
10
+ 4. Determines the Curie temperature as the value corresponding to the minimal (negative)
11
+ slope of the interpolated curve.
10
12
  """
11
13
 
12
14
  import json
@@ -17,14 +19,11 @@ from scipy.interpolate import interp1d
17
19
 
18
20
 
19
21
  class MagData:
20
- """
21
- Class to handle magnetization data and interpolation according to temperature
22
- """
22
+ """Class to handle magnetization data and interpolation according to temperature."""
23
23
 
24
24
  n_interp = 200
25
25
 
26
26
  def __init__(self, job_dir: Path = None, run_file: Path = Path("run.json")) -> None:
27
-
28
27
  if job_dir:
29
28
  self.parentpath = job_dir
30
29
  data, self.run = self.process_slurm_jobs()
@@ -65,16 +64,18 @@ class MagData:
65
64
  run = json.load(f)
66
65
  # Adding temperature and averaging value to the data list
67
66
  data.extend(
68
- [[float(T), res["m1_mean"]] for T, res in run["results"].items()]
67
+ [
68
+ [float(T), res["m1_mean"]]
69
+ for T, res in run["results"].items()
70
+ ]
69
71
  )
70
72
  except FileNotFoundError:
71
- print(f"Warning: {json_filename} file not found " f"in {jobdir.as_posix()}")
73
+ print(f"Warning: {json_filename} file not found in {jobdir.as_posix()}")
72
74
 
73
75
  data.sort() # Sorting by increasing temperatures
74
76
 
75
77
  return np.array(data), run
76
78
 
77
-
78
79
  def process_json(json_filepath: Path) -> tuple[np.array, dict]:
79
80
  """
80
81
  Reads the run.json file and extracts result data.
@@ -98,8 +99,12 @@ class MagData:
98
99
  @property
99
100
  def T_Curie(self) -> float:
100
101
  """
101
- Return the Curie temperature defined as the temperature at
102
- which the magnetization is below 0.1
102
+ Return the Curie temperature.
103
+
104
+ It is defined as the temperature at which the magnetization is below 0.1.
105
+
106
+ Returns:
107
+ float: Curie temperature
103
108
  """
104
109
  i_max = np.where(0.1 - self.interp(self.T) > 0)[0].min()
105
- return self.T[i_max]
110
+ return self.T[i_max]