Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 13.1.0 2026-08-27

* Python
* Remove dep on pydantic-numpy to loosen numpy dep range
* Loosen numpy dep requirement to >=1.23.5

## 13.0.0 2026-08-19

* Rust
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cfsem"
version = "13.0.0"
version = "13.1.0"
edition = "2024"
authors = ["Commonwealth Fusion Systems <jlogan@cfs.energy>"]
license = "MIT"
Expand Down
21 changes: 15 additions & 6 deletions cfsem/solenoid_stress/solenoid_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
import findiff
import numpy as np
from numpy.typing import NDArray
from pydantic import ConfigDict
from pydantic_numpy.model import NumpyModel
from pydantic_numpy.typing import NpNDArray # Array of any type or dimensionality
from pydantic import BaseModel, ConfigDict, Field
from scipy import io, sparse
from scipy.sparse import csc_matrix as CSC
from scipy.sparse import csr_matrix as CSR
Expand Down Expand Up @@ -96,10 +94,16 @@ def solenoid_1d_structural_rhs(
return rhs


class SolenoidStress1D(NumpyModel):
model_config = ConfigDict(validate_assignment=True, frozen=True, extra="forbid")
class SolenoidStress1D(BaseModel):
model_config = ConfigDict(
validate_assignment=True,
frozen=True,
extra="forbid",
populate_by_name=True,
serialize_by_alias=True,
)

rgrid: NpNDArray
rgrid_: list[float] = Field(alias="rgrid")
"""[m] 1D grid of r-coordinates"""
elasticity_modulus: float
"""[Pa] diagonal terms in material property matrix"""
Expand All @@ -113,6 +117,11 @@ class SolenoidStress1D(NumpyModel):
can be useful as a linear operator. Alternatively, the system can be solved
using an LU solver with reduced memory usage and better numerical conditioning."""

@cached_property
def rgrid(self) -> NDArray[np.float64]:
"""[m] 1D grid of r-coordinates."""
return np.asarray(self.rgrid_)

@cached_property
def operators(self) -> SolenoidStress1DOperators:
"""
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ classifiers = [
"Programming Language :: Python :: Implementation :: CPython",
]
dependencies = [
"numpy >= 2",
"numpy >= 1.23.5",
"interpn[pydantic]>=0.8.2,<0.12",
"findiff ~= 0.13.1",
"pydantic ~= 2.0",
"pydantic-numpy ~= 6.0",
"scipy ~= 1.8",
]
license = "MIT"
Expand Down
5 changes: 3 additions & 2 deletions test/test_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from interpn import MultilinearRectilinear
from numpy.typing import NDArray
from scipy.constants import mu_0
from scipy.integrate import trapezoid
from scipy.special import ellipe, ellipk

import cfsem
Expand Down Expand Up @@ -109,10 +110,10 @@ def _flux_density_circular_filament_numerical(
a1 = (a**2 + r**2 + z**2 - 2.0 * r * a * np.sin(phis)) ** -1.5 # Shared denominator

Brs = a0 * z * np.sin(phis) * a1
Br = np.trapezoid(x=phis, y=Brs) # [T]
Br = trapezoid(x=phis, y=Brs) # [T]

Bzs = a0 * (a - r * np.sin(phis)) * a1
Bz = np.trapezoid(x=phis, y=Bzs) # [T]
Bz = trapezoid(x=phis, y=Bzs) # [T]

return Br, Bz # [T]

Expand Down
162 changes: 6 additions & 156 deletions uv.lock

Large diffs are not rendered by default.

Loading