diff --git a/doc/conf.py b/doc/conf.py index b99285648..77e746963 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -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" @@ -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", @@ -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 = [ diff --git a/src/struphy/feec/mass.py b/src/struphy/feec/mass.py index 5964f5f7c..94fcf8dba 100644 --- a/src/struphy/feec/mass.py +++ b/src/struphy/feec/mass.py @@ -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. diff --git a/src/struphy/feec/utilities.py b/src/struphy/feec/utilities.py index ee4ab95e9..c0c0c6057 100644 --- a/src/struphy/feec/utilities.py +++ b/src/struphy/feec/utilities.py @@ -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 diff --git a/src/struphy/fields_background/coil_fields/base.py b/src/struphy/fields_background/coil_fields/base.py index 331e89e7d..7be04cb66 100644 --- a/src/struphy/fields_background/coil_fields/base.py +++ b/src/struphy/fields_background/coil_fields/base.py @@ -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 diff --git a/src/struphy/geometry/utilities.py b/src/struphy/geometry/utilities.py index ccc159692..4e5a5d44d 100644 --- a/src/struphy/geometry/utilities.py +++ b/src/struphy/geometry/utilities.py @@ -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): diff --git a/src/struphy/models/variables.py b/src/struphy/models/variables.py index 3f47f1efe..d4306ebc1 100644 --- a/src/struphy/models/variables.py +++ b/src/struphy/models/variables.py @@ -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( @@ -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( diff --git a/src/struphy/pic/accumulation/filter.py b/src/struphy/pic/accumulation/filter.py index 2c73e3a06..42bf0885c 100644 --- a/src/struphy/pic/accumulation/filter.py +++ b/src/struphy/pic/accumulation/filter.py @@ -1,5 +1,6 @@ from dataclasses import dataclass +import cunumpy as xp import numpy as np from scipy.fft import irfft, rfft diff --git a/src/struphy/post_processing/cprofile_analyser.py b/src/struphy/post_processing/cprofile_analyser.py index 94bc2b1bf..ef3057d89 100644 --- a/src/struphy/post_processing/cprofile_analyser.py +++ b/src/struphy/post_processing/cprofile_analyser.py @@ -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() diff --git a/src/struphy/post_processing/orbits/orbits_tools.py b/src/struphy/post_processing/orbits/orbits_tools.py index 97eee89af..c04ff5f35 100644 --- a/src/struphy/post_processing/orbits/orbits_tools.py +++ b/src/struphy/post_processing/orbits/orbits_tools.py @@ -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") diff --git a/src/struphy/propagators/propagators_fields.py b/src/struphy/propagators/propagators_fields.py index 462c58f26..cb1102486 100644 --- a/src/struphy/propagators/propagators_fields.py +++ b/src/struphy/propagators/propagators_fields.py @@ -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): @@ -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: