Skip to content
Draft
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
27 changes: 23 additions & 4 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.


with open("../src/struphy/console/main.py") as f:
exec(f.read())

# -- Project information -----------------------------------------------------
import importlib.metadata

__version__ = importlib.metadata.version("struphy")

project = "struphy"
copyright = "2019-2025 (c) Struphy dev team | Max Planck Institute for Plasma Physics"
Expand Down Expand Up @@ -78,7 +82,10 @@
"primary_sidebar_end": ["sidebar-ethical-ads"],
"external_links": [
{"name": "Struphy repo", "url": "https://github.com/struphy-hub/struphy"},
{"name": "Struphy LinkedIn", "url": "https://www.linkedin.com/company/struphy/"},
{
"name": "Struphy LinkedIn",
"url": "https://www.linkedin.com/company/struphy/",
},
{
"name": "Struphy MatrixChat",
"url": "https://matrix.to/#/!wqjcJpsUvAbTPOUXen:mpg.de?via=mpg.de&via=academiccloud.de",
Expand Down Expand Up @@ -121,9 +128,21 @@
# }

# inheritance diagrams
inheritance_graph_attrs = dict(rankdir="LR", ratio="auto", size='"4.0, 20.0"', fontsize="8", resolution=300.0)

inheritance_node_attrs = dict(shape="ellipse", fontsize="8", height=0.25, color="maroon4", style="filled")
inheritance_graph_attrs = dict(
rankdir="LR",
ratio="auto",
size='"4.0, 20.0"',
fontsize="8",
resolution=300.0,
)

inheritance_node_attrs = dict(
shape="ellipse",
fontsize="8",
height=0.25,
color="maroon4",
style="filled",
)

# markdown parsing
myst_enable_extensions = [
Expand Down
3 changes: 1 addition & 2 deletions src/struphy/feec/mass.py
Original file line number Diff line number Diff line change
Expand Up @@ -2997,8 +2997,7 @@ def __isub__(self, M):
else:
return LinOpWithTransp.__sub__(self, M)

@staticmethod
def eval_quad(W, coeffs, out=None):
def eval_quad(self, W, coeffs, out=None):
"""
Evaluates a given FEM field defined by its coefficients at the L2 quadrature points.

Expand Down
12 changes: 4 additions & 8 deletions src/struphy/feec/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,23 +467,19 @@ def create_weight_weightedmatrix_hybrid(b, weight_pre, derham, accum_density, do

for aa, wspace in enumerate(derham.Vh_fem["2"].spaces):
# knot span indices of elements of local domain
spans_out = [
quad_grid[nquad].spans for quad_grid, nquad in zip(self.derham.get_quad_grids(wspace), derham.nquads)
]
spans_out = [quad_grid[nquad].spans for quad_grid, nquad in zip(derham.get_quad_grids(wspace), derham.nquads)]
# global start spline index on process
starts_out = [int(start) for start in wspace.coeff_space.starts]

# Iniitialize hybrid linear operators
# global quadrature points (flattened) and weights in format (local element, local weight)
pts = [quad_grid[nquad].points for quad_grid, nquad in zip(self.derham.get_quad_grids(wspace), derham.nquads)]
wts = [quad_grid[nquad].weights for quad_grid, nquad in zip(self.derham.get_quad_grids(wspace), derham.nquads)]
pts = [quad_grid[nquad].points for quad_grid, nquad in zip(derham.get_quad_grids(wspace), derham.nquads)]
wts = [quad_grid[nquad].weights for quad_grid, nquad in zip(derham.get_quad_grids(wspace), derham.nquads)]

p = wspace.degree

# evaluated basis functions at quadrature points of the space
basis_o = [
quad_grid[nquad].basis for quad_grid, nquad in zip(self.derham.get_quad_grids(wspace), derham.nquads)
]
basis_o = [quad_grid[nquad].basis for quad_grid, nquad in zip(derham.get_quad_grids(wspace), derham.nquads)]

pads_out = wspace.coeff_space.pads

Expand Down
1 change: 1 addition & 0 deletions src/struphy/fields_background/coil_fields/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from abc import ABCMeta, abstractmethod

import cunumpy as xp
import pandas as pd
from matplotlib import pyplot as plt
from pyevtk.hl import gridToVTK

Expand Down
2 changes: 2 additions & 0 deletions src/struphy/geometry/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def field_line_tracing(
R = xp.zeros((s_gr.size, x_gr.size), dtype=float)
Z = xp.zeros((s_gr.size, x_gr.size), dtype=float)

r_flux_surface = None

# function whose root must be found
for j, x in enumerate(x_gr):
for i, s in enumerate(s_gr):
Expand Down
4 changes: 2 additions & 2 deletions src/struphy/models/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def allocate(
self._n_to_save = n_markers

assert self._n_to_save <= self.particles.Np, (
f"The number of markers for which data should be stored (={self._n_to_save}) murst be <= than the total number of markers (={obj.Np})"
f"The number of markers for which data should be stored (={self._n_to_save}) murst be <= than the total number of markers (={self.particles.Np})"
)
if self._n_to_save > 0:
self._saved_markers = xp.zeros(
Expand Down Expand Up @@ -405,7 +405,7 @@ def allocate(
self._n_to_save = n_markers

assert self._n_to_save <= self.particles.Np, (
f"The number of markers for which data should be stored (={self._n_to_save}) murst be <= than the total number of markers (={obj.Np})"
f"The number of markers for which data should be stored (={self._n_to_save}) murst be <= than the total number of markers (={self.particles.Np})"
)
if self._n_to_save > 0:
self._saved_markers = xp.zeros(
Expand Down
1 change: 1 addition & 0 deletions src/struphy/pic/accumulation/filter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from dataclasses import dataclass

import cunumpy as xp
import numpy as np
from scipy.fft import irfft, rfft

Expand Down
2 changes: 1 addition & 1 deletion src/struphy/post_processing/cprofile_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_cprofile_data(path, print_callers=None):
p = pstats.Stats(os.path.join(path, "profile_tmp"), stream=stdout)
p.strip_dirs().sort_stats(SortKey.CUMULATIVE).print_stats()
stdout.close()

name_li = None
data_cprofile = dict()
with open(os.path.join(path, "profile_out.txt")) as f:
lines = f.readlines()
Expand Down
2 changes: 1 addition & 1 deletion src/struphy/post_processing/orbits/orbits_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def post_process_orbit_guiding_center(path_in, path_kinetics_species, species):
params = yaml.load(f, Loader=yaml.FullLoader)

# create domain for calculating markers' physical coordinates
domain, equil = setup_domain_and_equil(params)
domain, equil = model.setup_domain_and_equil(params)

# path for orbit data
path_orbits = os.path.join(path_kinetics_species, "orbits")
Expand Down
29 changes: 16 additions & 13 deletions src/struphy/propagators/propagators_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1639,22 +1639,23 @@ def __call__(self, dt):
_RHS2 = HybridM1.dot(self._RHS) + self._rhs

# TODO: unknown function 'pcg', use new solver API
a_new, info = pcg(
_LHS,
_RHS2,
self._pc,
x0=self._a,
tol=self._solver_params["tol"],
maxiter=self._solver_params["maxiter"],
verbose=self._solver_params["verbose"],
)
raise NotImplementedError("pcg solver not available, use new solver API!")
# a_new, info = pcg(
# _LHS,
# _RHS2,
# self._pc,
# x0=self._a,
# tol=self._solver_params["tol"],
# maxiter=self._solver_params["maxiter"],
# verbose=self._solver_params["verbose"],
# )

# write new coeffs into Propagator.variables
max_da = self.feec_vars_update(a_new)
print("++++====check_iteration_error=====+++++", max_da)
# max_da = self.feec_vars_update(a_new)
# print("++++====check_iteration_error=====+++++", max_da)
# we can modify the diff function in in_place_update to get another type errors
if max_da[0] < 10 ** (-6):
break
# if max_da[0] < 10 ** (-6):
# break

@classmethod
def options(cls):
Expand Down Expand Up @@ -7859,6 +7860,8 @@ def allocate(self):

solver_params = self.options.solver_params

u = self.variables.u.spline.vector

# Lifting for nontrivial boundary conditions
# derham had boundary conditions in eta1 direction, the following is in space Hdiv_0
if self._lifting:
Expand Down
Loading