nmag-python-3 0.0.2__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.
- anisotropy/__init__.py +28 -0
- anisotropy/anisotropy.py +13 -0
- anisotropy/evaluation.py +70 -0
- anisotropy/model.py +200 -0
- anisotropy/predefined.py +202 -0
- anisotropy/py.typed +1 -0
- anisotropy/values.py +84 -0
- mag_material/__init__.py +3 -0
- mag_material/mag_material.py +231 -0
- mag_material/parameters.py +150 -0
- mag_material/py.typed +1 -0
- nmag/__init__.py +36 -0
- nmag/backends.py +493 -0
- nmag/checkpoint.py +327 -0
- nmag/config.py +174 -0
- nmag/demag/__init__.py +39 -0
- nmag/demag/bem_operator.py +149 -0
- nmag/demag/geometry.py +134 -0
- nmag/demag/lindholm.py +133 -0
- nmag/demag/lindholm_fast.py +463 -0
- nmag/demag/linear.py +489 -0
- nmag/dynamics/__init__.py +255 -0
- nmag/output.py +27 -0
- nmag/parallel.py +45 -0
- nmag/py.typed +1 -0
- nmag/resources.py +38 -0
- nmag/simulation/__init__.py +519 -0
- nmag/simulation/anisotropy/__init__.py +5 -0
- nmag/simulation/anisotropy/fields.py +56 -0
- nmag/simulation/anisotropy/materials.py +138 -0
- nmag/simulation/demag/__init__.py +1 -0
- nmag/simulation/demag/bem/__init__.py +11 -0
- nmag/simulation/demag/bem/diagnostics.py +73 -0
- nmag/simulation/demag/bem/dirichlet.py +85 -0
- nmag/simulation/demag/bem/hierarchical.py +74 -0
- nmag/simulation/demag/bem/operator.py +292 -0
- nmag/simulation/demag/fem/__init__.py +11 -0
- nmag/simulation/demag/fem/assembly.py +114 -0
- nmag/simulation/demag/fem/charges.py +38 -0
- nmag/simulation/demag/fem/geometry.py +261 -0
- nmag/simulation/demag/fields/__init__.py +11 -0
- nmag/simulation/demag/fields/auxiliary.py +186 -0
- nmag/simulation/demag/fields/probe.py +77 -0
- nmag/simulation/demag/fields/recovery.py +207 -0
- nmag/simulation/demag/solver.py +17 -0
- nmag/simulation/dynamics/__init__.py +92 -0
- nmag/simulation/dynamics/advance.py +199 -0
- nmag/simulation/dynamics/integrator.py +263 -0
- nmag/simulation/exchange/__init__.py +13 -0
- nmag/simulation/exchange/coefficients.py +185 -0
- nmag/simulation/exchange/fields.py +106 -0
- nmag/simulation/exchange/llg_rhs.py +218 -0
- nmag/simulation/fields/__init__.py +19 -0
- nmag/simulation/fields/arrays.py +111 -0
- nmag/simulation/fields/availability.py +188 -0
- nmag/simulation/fields/averages.py +293 -0
- nmag/simulation/fields/derived.py +164 -0
- nmag/simulation/fields/maxangle.py +163 -0
- nmag/simulation/fields/probes.py +106 -0
- nmag/simulation/implicit_dynamics.py +221 -0
- nmag/simulation/mesh/__init__.py +13 -0
- nmag/simulation/mesh/geometry.py +153 -0
- nmag/simulation/mesh/materials.py +299 -0
- nmag/simulation/mesh/probe.py +234 -0
- nmag/simulation/restart.py +103 -0
- nmag/simulation/support.py +224 -0
- nmag_python_3-0.0.2.dist-info/METADATA +157 -0
- nmag_python_3-0.0.2.dist-info/RECORD +147 -0
- nmag_python_3-0.0.2.dist-info/WHEEL +5 -0
- nmag_python_3-0.0.2.dist-info/licenses/LICENSE +339 -0
- nmag_python_3-0.0.2.dist-info/top_level.txt +8 -0
- nmesh/__init__.py +130 -0
- nmesh/backend.py +286 -0
- nmesh/geometry/__init__.py +52 -0
- nmesh/geometry/boolean_operations.py +157 -0
- nmesh/geometry/primitives.py +453 -0
- nmesh/geometry/transform.py +126 -0
- nmesh/io/__init__.py +50 -0
- nmesh/io/ascii.py +132 -0
- nmesh/io/legacy_nmesh_hdf5.py +318 -0
- nmesh/io/meshio_support.py +170 -0
- nmesh/mesh_generation.py +182 -0
- nmesh/mesh_io.py +227 -0
- nmesh/mesh_model.py +147 -0
- nmesh/mesh_utilities.py +79 -0
- nmesh/mesher/__init__.py +21 -0
- nmesh/mesher/driver.py +146 -0
- nmesh/mesher/meshing_defaults.py +252 -0
- nmesh/mesher/meshing_parameters.py +185 -0
- nmesh/mesher/parity.py +21 -0
- nmesh/mesher/parity_canonical.py +142 -0
- nmesh/mesher/parity_comparison.py +191 -0
- nmesh/mesher/parity_metrics.py +114 -0
- nmesh/mesher/periodic.py +97 -0
- nmesh/mesher/relaxation/__init__.py +14 -0
- nmesh/mesher/relaxation/_constants.py +20 -0
- nmesh/mesher/relaxation/_types.py +15 -0
- nmesh/mesher/relaxation/density.py +170 -0
- nmesh/mesher/relaxation/engine/__init__.py +18 -0
- nmesh/mesher/relaxation/engine/state.py +155 -0
- nmesh/mesher/relaxation/engine/steps.py +248 -0
- nmesh/mesher/relaxation/engine/topology.py +230 -0
- nmesh/mesher/relaxation/forces/__init__.py +96 -0
- nmesh/mesher/relaxation/forces/jit.py +102 -0
- nmesh/mesher/relaxation/forces/neighbors.py +186 -0
- nmesh/mesher/relaxation/forces/simplex.py +302 -0
- nmesh/mesher/relaxation/forces/summary.py +207 -0
- nmesh/mesher/relaxation/forces/types.py +92 -0
- nmesh/mesher/relaxation/geometry/__init__.py +6 -0
- nmesh/mesher/relaxation/geometry/builder.py +154 -0
- nmesh/mesher/relaxation/geometry/model.py +194 -0
- nmesh/mesher/relaxation/seeding/__init__.py +74 -0
- nmesh/mesher/relaxation/seeding/periodic.py +88 -0
- nmesh/mesher/relaxation/seeding/points.py +88 -0
- nmesh/mesher/relaxation/seeding/sampling.py +142 -0
- nmesh/mesher/relaxation/topology/__init__.py +297 -0
- nmesh/mesher/relaxation/topology/finalize.py +78 -0
- nmesh/mesher/relaxation/topology/recovery.py +310 -0
- nmesh/mesher/sectioned_config.py +70 -0
- nmesh/nmesh.py +99 -0
- nmesh/py.typed +1 -0
- nmesh/utils/__init__.py +33 -0
- nmesh/utils/array_list_utils.py +128 -0
- nmesh/utils/constants.py +22 -0
- nmesh/utils/timing_memory_utils.py +51 -0
- nmesh/utils/types.py +13 -0
- si/constants.py +49 -0
- si/physical.py +722 -0
- si/py.typed +1 -0
- simulation/__init__.py +1 -0
- simulation/clock.py +237 -0
- simulation/data_writer.py +273 -0
- simulation/data_writer_collection.py +267 -0
- simulation/hysteresis.py +74 -0
- simulation/hysteresis_runner.py +286 -0
- simulation/hysteresis_schedule.py +180 -0
- simulation/inference/__init__.py +3 -0
- simulation/inference/inference.py +95 -0
- simulation/py.typed +1 -0
- simulation/quantity.py +88 -0
- simulation/simulation_core.py +458 -0
- throttler/__init__.py +3 -0
- throttler/py.typed +1 -0
- throttler/throttler.py +55 -0
- when/__init__.py +3 -0
- when/py.typed +1 -0
- when/when.py +416 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
import re
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
log = logging.getLogger(__name__)
|
|
7
|
+
|
|
8
|
+
_time_zero: float | None = None
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def time_passed() -> float:
|
|
12
|
+
"""Returns elapsed time since the first call to this function."""
|
|
13
|
+
global _time_zero
|
|
14
|
+
if _time_zero is None:
|
|
15
|
+
_time_zero = time.time()
|
|
16
|
+
return 0.0
|
|
17
|
+
return time.time() - _time_zero
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def memstats(self_status_file: str = "/proc/self/status") -> list[float]:
|
|
21
|
+
"""Reads VmSize and VmRSS from /proc/self/status (Linux)."""
|
|
22
|
+
vmsize_vmrss = [0.0, 0.0]
|
|
23
|
+
if not os.path.exists(self_status_file):
|
|
24
|
+
return vmsize_vmrss
|
|
25
|
+
|
|
26
|
+
# Matches "VmSize: 1234 kB" or "VmRSS: 5678 KB".
|
|
27
|
+
re_pattern = re.compile(r"^(VmSize|VmRSS):\s+(\d+)\s+[kK][bB]", re.MULTILINE)
|
|
28
|
+
try:
|
|
29
|
+
with open(self_status_file) as fd:
|
|
30
|
+
content = fd.read()
|
|
31
|
+
found = 0
|
|
32
|
+
for match in re_pattern.finditer(content):
|
|
33
|
+
key = match.group(1)
|
|
34
|
+
value = float(match.group(2))
|
|
35
|
+
if key == "VmSize":
|
|
36
|
+
vmsize_vmrss[0] = value
|
|
37
|
+
else:
|
|
38
|
+
vmsize_vmrss[1] = value
|
|
39
|
+
found += 1
|
|
40
|
+
if found >= 2:
|
|
41
|
+
break
|
|
42
|
+
except Exception as e:
|
|
43
|
+
log.debug(f"Failed to read memstats: {e}")
|
|
44
|
+
return vmsize_vmrss
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def time_vmem_rss() -> tuple[float, float, float]:
|
|
48
|
+
"""Returns (elapsed_time, vmem, rss) where memory is in KB."""
|
|
49
|
+
t = time_passed()
|
|
50
|
+
mem = memstats()
|
|
51
|
+
return t, mem[0], mem[1]
|
nmesh/utils/types.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Common type aliases used throughout the nmesh package."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, TypeAlias
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
from numpy.typing import NDArray
|
|
7
|
+
|
|
8
|
+
__all__ = ["ArrayLike", "FloatArray", "BoolArray", "IntArray"]
|
|
9
|
+
|
|
10
|
+
ArrayLike: TypeAlias = Any
|
|
11
|
+
FloatArray: TypeAlias = NDArray[np.float64]
|
|
12
|
+
BoolArray: TypeAlias = NDArray[np.bool_]
|
|
13
|
+
IntArray: TypeAlias = NDArray[np.int_]
|
si/constants.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Original file: https://github.com/nmag-project/nmag-src/blob/master/interface/nsim/si_units/si.py
|
|
3
|
+
Some useful SI constants, defined using the pint library's authoritative values.
|
|
4
|
+
|
|
5
|
+
This module provides common physical constants as pint Quantity objects
|
|
6
|
+
for direct use in calculations. It replaces hard-coded values with references
|
|
7
|
+
to the pint library's built-in constants, which are based on up-to-date
|
|
8
|
+
CODATA values.
|
|
9
|
+
https://github.com/hgrecco/pint/blob/master/pint/default_en.txt
|
|
10
|
+
https://github.com/hgrecco/pint/blob/master/pint/constants_en.txt
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from si.physical import ureg
|
|
14
|
+
|
|
15
|
+
# --- Base and Common Units ---
|
|
16
|
+
kilogram = ureg.kilogram
|
|
17
|
+
meter = ureg.meter
|
|
18
|
+
metre = meter # alternative spelling
|
|
19
|
+
Ampere = ureg.ampere
|
|
20
|
+
Kelvin = ureg.kelvin
|
|
21
|
+
second = ureg.second
|
|
22
|
+
candela = ureg.candela
|
|
23
|
+
mol = ureg.mole
|
|
24
|
+
Joule = ureg.joule
|
|
25
|
+
Newton = ureg.newton
|
|
26
|
+
Tesla = ureg.tesla
|
|
27
|
+
Gauss = ureg.gauss
|
|
28
|
+
|
|
29
|
+
# --- Physical Constants (from pint's library) ---
|
|
30
|
+
|
|
31
|
+
mu0 = ureg.mu_0
|
|
32
|
+
Oersted = ureg.oersted
|
|
33
|
+
Oe = Oersted
|
|
34
|
+
bohr_magneton = ureg.bohr_magneton
|
|
35
|
+
positron_charge = ureg.e
|
|
36
|
+
electron_charge = -1 * ureg.e
|
|
37
|
+
boltzmann_constant = ureg.k
|
|
38
|
+
plank_constant = ureg.h
|
|
39
|
+
reduced_plank_constant = ureg.hbar
|
|
40
|
+
|
|
41
|
+
# --- Custom or Specific Values ---
|
|
42
|
+
|
|
43
|
+
degrees_per_ns = 1 * ureg.degree / ureg.nanosecond
|
|
44
|
+
|
|
45
|
+
gamma_e = (ureg.g_e * ureg.e) / (2 * ureg.m_e)
|
|
46
|
+
# This constant, often used in micromagnetics, is the product of the
|
|
47
|
+
# electron gyromagnetic ratio (gamma_e) and the vacuum permeability (mu_0).
|
|
48
|
+
# The negative sign is a convention used in the LLG equation.
|
|
49
|
+
gamma0 = -1 * gamma_e * ureg.mu_0
|