Perturbation functions#

Analytical perturbations.

class struphy.initial.perturbations.Noise(direction: Literal['e1', 'e2', 'e3', 'e1e2', 'e1e3', 'e2e3', 'e1e2e3'] = 'e3', amp: float = 0.0001, seed: int | None = None, comp: int = 0, given_in_basis: Literal['0', '1', '2', '3', 'v', 'physical', 'physical_at_eta', 'norm', None] = '0')[source]#

Bases: Perturbation

White noise for FEEC coefficients.

Parameters:
  • direction (str) – The direction(s) of variation of the noise: ‘e1’, ‘e2’, ‘e3’, ‘e1e2’, etc.

  • amp (float) – Noise amplitude.

  • seed (int) – Seed for the random number generator.

class struphy.initial.perturbations.ModesSin(ls: tuple[int] | None = None, ms: tuple[int] | None = None, ns: tuple[int] | None = None, amps: tuple[float] = (0.0001,), theta: tuple[float] | None = None, pfuns=('Id',), pfuns_params=(0.0,), Lx=1.0, Ly=1.0, Lz=1.0, given_in_basis: Literal['0', '1', '2', '3', 'v', 'physical', 'physical_at_eta', 'norm', None] = '0', comp: int = 0)[source]#

Bases: Perturbation

Sinusoidal function in 3D.

\[u(x, y, z) = \sum_{s} \chi_s(z) A_s \sin \left(l_s \frac{2\pi}{L_x} x + m_s \frac{2\pi}{L_y} y + n_s \frac{2\pi}{L_z} z + \theta_s \right) \,.\]

where \(\chi_s(z)\) is one of

\[\begin{split}\chi_s(z) = \left\{ \begin{aligned} 1\,, \\[2mm] \tanh((z - 0.5)/\delta)/\cosh((z - 0.5)/\delta)\,, \end{aligned} \right.\end{split}\]

Can be used in logical space (use ‘given_in_basis’), where \(x \to \eta_1,\, y\to \eta_2,\, z \to \eta_3\) and \(L_x=L_y=L_z=1.0\) (default).

Parameters:
  • ls (tuple[int]) – Mode numbers in x-direction (kx = l*2*pi/Lx).

  • ms (tuple[int]) – Mode numbers in y-direction (ky = m*2*pi/Ly).

  • ns (tuple[int]) – Mode numbers in z-direction (kz = n*2*pi/Lz).

  • amps (tuple[float]) – Amplitude of each mode.

  • theta (tuple | list) – Phase of each mode.

  • pfuns (tuple | list[str]) – “Id” or “localize” define the profile functions. localize multiply the sinus by :math: tanh((eta_3 - 0.5)/delta)/cosh((eta_3 - 0.5)/delta) to localize it around 0.5. :math: delta is given by the input parameter pfuns_params

  • pfuns_params (tuple | list) – The parameter needed by the profile function

  • Lx (float) – Domain lengths.

  • Ly (float) – Domain lengths.

  • Lz (float) – Domain lengths.

  • given_in_basis (str) – In which basis the perturbation is represented (see base class).

  • comp (int) – Which component (0, 1 or 2) of vector is perturbed (=0 for scalar-valued functions)

class struphy.initial.perturbations.ModesCos(ls: tuple[int] | None = None, ms: tuple[int] | None = None, ns: tuple[int] | None = None, amps: tuple[float] = (0.0001,), Lx=1.0, Ly=1.0, Lz=1.0, given_in_basis: Literal['0', '1', '2', '3', 'v', 'physical', 'physical_at_eta', 'norm', None] = '0', comp: int = 0)[source]#

Bases: Perturbation

Cosinusoidal function in 3D.

\[u(x, y, z) = \sum_{s} A_s \cos \left(l_s \frac{2\pi}{L_x} x + m_s \frac{2\pi}{L_y} y + n_s \frac{2\pi}{L_z} z \right) \,.\]

Can be used in logical space (use ‘given_in_basis’), where \(x \to \eta_1,\, y\to \eta_2,\, z \to \eta_3\) and \(L_x=L_y=L_z=1.0\) (default).

Parameters:
  • ls (tuple[int]) – Mode numbers in x-direction (kx = l*2*pi/Lx).

  • ms (tuple[int]) – Mode numbers in y-direction (ky = m*2*pi/Ly).

  • ns (tuple[int]) – Mode numbers in z-direction (kz = n*2*pi/Lz).

  • amps (tuple[float]) – Amplitude of each mode.

  • Lx (float) – Domain lengths.

  • Ly (float) – Domain lengths.

  • Lz (float) – Domain lengths.

  • given_in_basis (str) – In which basis the perturbation is represented (see base class).

  • comp (int) – Which component (0, 1 or 2) of vector is perturbed (=0 for scalar-valued functions)

class struphy.initial.perturbations.CoaxialWaveguideElectric_r(m=1, a1=1.0, a2=2.0, a=1, b=-0.28)[source]#

Bases: Perturbation

Initializes function for Coaxial Waveguide electric field in radial direction.

Solutions taken from TUM master thesis of Alicia Robles Pérez: “Development of a Geometric Particle-in-Cell Method for Cylindrical Coordinate Systems”, 2024

Parameters:
  • m (int) – Number of Modes

  • a1 (float) – inner and outer radius of Hollow Cylinder

  • a2 (float) – inner and outer radius of Hollow Cylinder

  • a (float) – Parameters of Electric field

  • b (float) – Parameters of Electric field

class struphy.initial.perturbations.CoaxialWaveguideElectric_theta(m=1, a1=1.0, a2=2.0, a=1, b=-0.28)[source]#

Bases: Perturbation

Initializes funtion for Coaxial Waveguide electric field in the azimuthal direction.

Solutions taken from TUM master thesis of Alicia Robles Pérez: “Development of a Geometric Particle-in-Cell Method for Cylindrical Coordinate Systems”, 2024

Parameters:
  • m (int) – Number of Modes

  • a1 (float) – inner and outer radius of Hollow Cylinder

  • a2 (float) – inner and outer radius of Hollow Cylinder

  • a (float) – Parameters of Electric field

  • b (float) – Parameters of Electric field

class struphy.initial.perturbations.CoaxialWaveguideMagnetic(m=1, a1=1.0, a2=2.0, a=1, b=-0.28)[source]#

Bases: Perturbation

Initializes funtion for Coaxial Waveguide magnetic field in $z$-direction.

Solutions taken from TUM master thesis of Alicia Robles Pérez: “Development of a Geometric Particle-in-Cell Method for Cylindrical Coordinate Systems”, 2024

Parameters:
  • m (int) – Number of Modes

  • a1 (float) – inner and outer radius of Hollow Cylinder

  • a2 (float) – inner and outer radius of Hollow Cylinder

  • a (float) – Parameters of Electric field

  • b (float) – Parameters of Electric field

class struphy.initial.perturbations.ModesCosCos(ls=None, ms=None, amps=(0.0001,), theta_x=None, theta_y=None, pfuns=('Id',), pfuns_params=(0.0,), Lx=1.0, Ly=1.0, Lz=1.0, given_in_basis: Literal['0', '1', '2', '3', 'v', 'physical', 'physical_at_eta', 'norm', None] = '0', comp: int = 0)[source]#

Bases: Perturbation

\[u(x, y, z) = \sum_s A_s \, \chi_s(z) \cos \!\left(l_s \tfrac{2\pi}{L_x} x + \theta_{x,s}\right) \cos \!\left(m_s \tfrac{2\pi}{L_y} y + \theta_{y,s}\right)\]

where \(\chi_s(z)\) can be either 1 or localized in z.

class struphy.initial.perturbations.ModesSinSin(ls=None, ms=None, amps=(0.0001,), theta_x=None, theta_y=None, pfuns=('Id',), pfuns_params=(0.0,), Lx=1.0, Ly=1.0, Lz=1.0, given_in_basis: Literal['0', '1', '2', '3', 'v', 'physical', 'physical_at_eta', 'norm', None] = '0', comp: int = 0)[source]#

Bases: Perturbation

\[u(x, y, z) = \sum_s A_s \, \chi_s(z) \sin \!\left(l_s \tfrac{2\pi}{L_x} x + \theta_{x,s}\right) \sin \!\left(m_s \tfrac{2\pi}{L_y} y + \theta_{y,s}\right)\]

where \(\chi_s(z)\) can be either 1 or localized in z.

class struphy.initial.perturbations.ModesSinCos(ls=None, ms=None, amps=(0.0001,), theta_x=None, theta_y=None, pfuns=('Id',), pfuns_params=(0.0,), Lx=1.0, Ly=1.0, Lz=1.0, given_in_basis: Literal['0', '1', '2', '3', 'v', 'physical', 'physical_at_eta', 'norm', None] = '0', comp: int = 0)[source]#

Bases: Perturbation

\[u(x, y, z) = \sum_s A_s \, \chi_s(z) \sin \!\left(l_s \tfrac{2\pi}{L_x} x + \theta_{x,s}\right) \cos \!\left(m_s \tfrac{2\pi}{L_y} y + \theta_{y,s}\right)\]

where \(\chi_s(z)\) can be either 1 or localized in z.

class struphy.initial.perturbations.ModesCosSin(ls=None, ms=None, amps=(0.0001,), theta_x=None, theta_y=None, pfuns=('Id',), pfuns_params=(0.0,), Lx=1.0, Ly=1.0, Lz=1.0, given_in_basis: Literal['0', '1', '2', '3', 'v', 'physical', 'physical_at_eta', 'norm', None] = '0', comp: int = 0)[source]#

Bases: Perturbation

\[u(x, y, z) = \sum_s A_s \, \chi_s(z) \cos \!\left(l_s \tfrac{2\pi}{L_x} x + \theta_{x,s}\right) \sin \!\left(m_s \tfrac{2\pi}{L_y} y + \theta_{y,s}\right)\]

where \(\chi_s(z)\) can be either 1 or localized in z.

class struphy.initial.perturbations.TorusModesSin(ms=None, ns=None, amps=(0.0001,), pfuns=('sin',), pfun_params=None, given_in_basis: Literal['0', '1', '2', '3', 'v', 'physical', 'physical_at_eta', 'norm', None] = '0', comp: int = 0)[source]#

Bases: Perturbation

Sinusoidal function in the periodic coordinates of a Torus.

\[u(\eta_1, \eta_2, \eta_3) = \sum_{s} \chi_s(\eta_1) A_s \sin(m_s\,2\pi \eta_2 + n_s\,2\pi \eta_3) \,,\]

where \(\chi_s(\eta_1)\) is one of

\[\begin{split}\chi_s(\eta_1) = \left\{ \begin{aligned} &\sin(l_s\pi\eta_1)\,, \\[2mm] &\exp \left(- \frac{(\eta_1 - r_0)^2}{2 \sigma^2} \right) \,, \\[2mm] & - \frac{\eta_1 - r_0}{\sigma} \exp \left(- \frac{(\eta_1 - r_0)^2}{2 \sigma^2} \right) \,. \end{aligned} \right.\end{split}\]

Can ony be used in logical space (use ‘given_in_basis’).

Parameters:
  • ms (tuple | list[int]) – Poloidal mode numbers.

  • ns (tuple | list[int]) – Toroidal mode numbers.

  • pfuns (tuple | list[str]) – “sin” or “cos” or “exp” to define the profile functions.

  • amps (tuple | list[float]) – Amplitudes of each mode (m_i, n_i).

  • pfun_params (tuple | list) – Provides \([r_0, \sigma]\) parameters for each “exp” profile fucntion, and l_s for “sin” and “cos”.

  • given_in_basis (str) – In which basis the perturbation is represented (see base class).

  • comp (int) – Which component (0, 1 or 2) of vector is perturbed (=0 for scalar-valued functions)

class struphy.initial.perturbations.TorusModesCos(ms: tuple = (2,), ns: tuple = (1,), amps: tuple = (0.1,), pfuns: tuple = ('sin',), pfun_params=None, given_in_basis: Literal['0', '1', '2', '3', 'v', 'physical', 'physical_at_eta', 'norm', None] = '0', comp: int = 0)[source]#

Bases: Perturbation

Cosinusoidal function in the periodic coordinates of a Torus.

\[u(\eta_1, \eta_2, \eta_3) = \sum_{s} \chi_s(\eta_1) A_s \cos(m_s\,2\pi \eta_2 + n_s\,2\pi \eta_3) \,,\]

where \(\chi_s(\eta_1)\) is one of

\[\begin{split}\chi_s(\eta_1) = \left\{ \begin{aligned} &\sin(\pi\eta_1)\,, \\[2mm] &\exp \left(- \frac{(\eta_1 - r_0)^2}{2 \sigma^2} \right) \,, \\[2mm] & - \frac{\eta_1 - r_0}{\sigma} \exp \left(- \frac{(\eta_1 - r_0)^2}{2 \sigma^2} \right) \,. \end{aligned} \right.\end{split}\]

Can only be used in logical space (use ‘given_in_basis’).

Parameters:
  • ms (tuple[int]) – Poloidal mode numbers.

  • ns (tuple[int]) – Toroidal mode numbers.

  • pfuns (tuple[str]) – “sin” or “cos” or “exp” to define the profile functions.

  • amps (tuple[float]) – Amplitudes of each mode (m_i, n_i).

  • pfun_params (tuple | list) – Provides \([r_0, \sigma]\) parameters for each “exp” profile fucntion, and l_s for “sin” and “cos”.

  • given_in_basis (str) – In which basis the perturbation is represented (see base class).

  • comp (int) – Which component (0, 1 or 2) of vector is perturbed (=0 for scalar-valued functions)

class struphy.initial.perturbations.Shear_x(amp=0.0001, delta=0.06666666666666667, given_in_basis: Literal['0', '1', '2', '3', 'v', 'physical', 'physical_at_eta', 'norm', None] = '0', comp: int = 0)[source]#

Bases: Perturbation

Double shear layer in eta1 (-1 in outer regions, 1 in inner regions).

\[u(\eta_1, \eta_2, \eta_3) = A(-\tanh((\eta_1 - 0.25)/\delta)+\tanh((\eta_1 - 0.75)/\delta) - 1) \,.\]

Can only be used in logical space.

Parameters:
  • amps (float) – Amplitude of the velocity on each side.

  • delta (float) – Characteristic size of the shear layer

  • given_in_basis (str) – In which basis the perturbation is represented (see base class).

  • comp (int) – Which component (0, 1 or 2) of vector is perturbed (=0 for scalar-valued functions)

class struphy.initial.perturbations.Shear_y(amp=0.0001, delta=0.06666666666666667, given_in_basis: Literal['0', '1', '2', '3', 'v', 'physical', 'physical_at_eta', 'norm', None] = '0', comp: int = 0)[source]#

Bases: Perturbation

Double shear layer in eta2 (-1 in outer regions, 1 in inner regions).

\[u(\eta_1, \eta_2, \eta_3) = A(-\tanh((\eta_2 - 0.25)/\delta) + \tanh((\eta_2 - 0.75)/\delta) - 1) \,.\]

Can only be used in logical space.

Parameters:
  • amps (float) – Amplitude of the velocity on each side.

  • delta (float) – Characteristic size of the shear layer

  • given_in_basis (str) – In which basis the perturbation is represented (see base class).

  • comp (int) – Which component (0, 1 or 2) of vector is perturbed (=0 for scalar-valued functions)

class struphy.initial.perturbations.Shear_z(amp=0.0001, delta=0.06666666666666667, given_in_basis: Literal['0', '1', '2', '3', 'v', 'physical', 'physical_at_eta', 'norm', None] = '0', comp: int = 0)[source]#

Bases: Perturbation

Double shear layer in eta3 (-1 in outer regions, 1 in inner regions).

\[u(\eta_1, \eta_2, \eta_3) = A(-\tanh((\eta_3 - 0.25)/\delta) + \tanh((\eta_3 - 0.75)/\delta) - 1) \,.\]

Can only be used in logical space.

Parameters:
  • amps (float) – Amplitude of the velocity on each side.

  • delta (float) – Characteristic size of the shear layer

  • given_in_basis (str) – In which basis the perturbation is represented (see base class).

  • comp (int) – Which component (0, 1 or 2) of vector is perturbed (=0 for scalar-valued functions)

class struphy.initial.perturbations.Erf_z(amp=0.0001, delta=0.06666666666666667, given_in_basis: Literal['0', '1', '2', '3', 'v', 'physical', 'physical_at_eta', 'norm', None] = '0', comp: int = 0)[source]#

Bases: Perturbation

Shear layer in eta3 (-1 in lower regions, 1 in upper regions).

\[u(\eta_1, \eta_2, \eta_3) = A \, erf((\eta_3 - 0.5)/\delta) \,.\]

Can only be used in logical space.

Parameters:
  • amp (float) – Amplitude of the velocity on each side.

  • delta (float) – Characteristic size of the shear layer

  • given_in_basis (str) – In which basis the perturbation is represented (see base class).

  • comp (int) – Which component (0, 1 or 2) of vector is perturbed (=0 for scalar-valued functions)

class struphy.initial.perturbations.RestelliAnalyticSolutionVelocity(a=1.0, R0=2.0, B0=10.0, Bp=12.5, alpha=0.1, beta=1.0, comp: int = 0)[source]#

Bases: Perturbation

Analytic solution \(u=u_e\) of the system:

\[\begin{split}\partial_t u = - \nabla \phi + u \times B + \nu \Delta u + f \,,\\ 0 = \nabla \phi- u_e \times B + \nu_e \Delta u_e + f_e \,, \\ \nabla \cdot (u-u_e) = 0 \,.\end{split}\]

where \(f\) is defined as follows:

\[\begin{split}f = \nu \omega \,, \\[2mm] \omega = \left[0, \alpha \frac{R_0 - 4R}{a R_0 R} - \beta \frac{B_p}{B_0}\frac{R_0^2}{a R^3}, 0 \right] \,, \\[2mm] R = \sqrt{x^2 + y^2} \,.\end{split}\]

Can only be defined in Cartesian coordinates. The solution is given by:

\[\begin{split}\alpha \frac{R}{a R_0} \left[\begin{array}{c} -z \\ R-R_0 \\ 0 \end{array} \right] + \beta \frac{B_p}{B_0} \frac{R_0}{aR} \left[\begin{array}{c} z \\ -(R-R_0) \\ \frac{B_0}{B_p} a \end{array} \right] \,, \\[2mm] R = \sqrt{x^2 + y^2} \,.\end{split}\]
Parameters:
  • a (float) – Minor radius of torus (default: 1.).

  • R0 (float) – Major radius of torus (default: 2.).

  • B0 (float) – On-axis (r=0) toroidal magnetic field (default: 10.).

  • Bp (float) – Poloidal magnetic field (default: 12.5).

  • alpha (float) – (default: 0.1)

  • beta (float) – (default: 1.0)

  • comp (int) – Which component (0, 1 or 2) of vector is perturbed (=0 for scalar-valued functions)

References

[1] Juan Vicente Gutiérrez-Santacreu, Omar Maj, Marco Restelli: Finite element discretization of a Stokes-like model arising in plasma physics, Journal of Computational Physics 2018.

class struphy.initial.perturbations.RestelliAnalyticSolutionVelocity_2(a=1.0, R0=2.0, B0=10.0, Bp=12.5, alpha=0.1, beta=1.0, comp: int = 0)[source]#

Bases: Perturbation

Analytic solution \(u=u_e\) of the system:

\[\begin{split}\partial_t u = - \nabla \phi + u \times B + \nu \Delta u + f \,,\\ 0 = \nabla \phi- u_e \times B + \nu_e \Delta u_e + f_e \,, \\ \nabla \cdot (u-u_e) = 0 \,.\end{split}\]

where \(f\) is defined as follows:

\[\begin{split}f = \nu \omega \,, \\[2mm] \omega = \left[0, \alpha \frac{R_0 - 4R}{a R_0 R} - \beta \frac{B_p}{B_0}\frac{R_0^2}{a R^3}, 0 \right] \,, \\[2mm] R = \sqrt{x^2 + y^2} \,.\end{split}\]

Can only be defined in Cartesian coordinates. The solution is given by:

\[\begin{split}\alpha \frac{R}{a R_0} \left[\begin{array}{c} -z \\ R-R_0 \\ 0 \end{array} \right] + \beta \frac{B_p}{B_0} \frac{R_0}{aR} \left[\begin{array}{c} z \\ -(R-R_0) \\ \frac{B_0}{B_p} a \end{array} \right] \,, \\[2mm] R = \sqrt{x^2 + y^2} \,.\end{split}\]
Parameters:
  • a (float) – Minor radius of torus (default: 1.).

  • R0 (float) – Major radius of torus (default: 2.).

  • B0 (float) – On-axis (r=0) toroidal magnetic field (default: 10.).

  • Bp (float) – Poloidal magnetic field (default: 12.5).

  • alpha (float) – (default: 0.1)

  • beta (float) – (default: 1.0)

  • comp (int) – Which component (0, 1 or 2) of vector is perturbed (=0 for scalar-valued functions)

References

[1] Juan Vicente Gutiérrez-Santacreu, Omar Maj, Marco Restelli: Finite element discretization of a Stokes-like model arising in plasma physics, Journal of Computational Physics 2018.

class struphy.initial.perturbations.RestelliAnalyticSolutionVelocity_3(a=1.0, R0=2.0, B0=10.0, Bp=12.5, alpha=0.1, beta=1.0, comp: int = 0)[source]#

Bases: Perturbation

Analytic solution \(u=u_e\) of the system:

\[\begin{split}\partial_t u = - \nabla \phi + u \times B + \nu \Delta u + f \,,\\ 0 = \nabla \phi- u_e \times B + \nu_e \Delta u_e + f_e \,, \\ \nabla \cdot (u-u_e) = 0 \,.\end{split}\]

where \(f\) is defined as follows:

\[\begin{split}f = \nu \omega \,, \\[2mm] \omega = \left[0, \alpha \frac{R_0 - 4R}{a R_0 R} - \beta \frac{B_p}{B_0}\frac{R_0^2}{a R^3}, 0 \right] \,, \\[2mm] R = \sqrt{x^2 + y^2} \,.\end{split}\]

Can only be defined in Cartesian coordinates. The solution is given by:

\[\begin{split}\alpha \frac{R}{a R_0} \left[\begin{array}{c} -z \\ R-R_0 \\ 0 \end{array} \right] + \beta \frac{B_p}{B_0} \frac{R_0}{aR} \left[\begin{array}{c} z \\ -(R-R_0) \\ \frac{B_0}{B_p} a \end{array} \right] \,, \\[2mm] R = \sqrt{x^2 + y^2} \,.\end{split}\]
Parameters:
  • a (float) – Minor radius of torus (default: 1.).

  • R0 (float) – Major radius of torus (default: 2.).

  • B0 (float) – On-axis (r=0) toroidal magnetic field (default: 10.).

  • Bp (float) – Poloidal magnetic field (default: 12.5).

  • alpha (float) – (default: 0.1)

  • beta (float) – (default: 1.0)

  • comp (int) – Which component (0, 1 or 2) of vector is perturbed (=0 for scalar-valued functions)

References

[1] Juan Vicente Gutiérrez-Santacreu, Omar Maj, Marco Restelli: Finite element discretization of a Stokes-like model arising in plasma physics, Journal of Computational Physics 2018.

class struphy.initial.perturbations.RestelliAnalyticSolutionPotential(a=1.0, R0=2.0, B0=10.0, Bp=12.5, alpha=0.1, beta=1.0)[source]#

Bases: Perturbation

Analytic solution \(\phi\) of the system:

\[\begin{split}\partial_t u = - \nabla \phi + u \times B + \nu \Delta u + f \,,\\ 0 = \nabla \phi- u_e \times B + \nu_e \Delta u_e + f_e \,, \\ \nabla \cdot (u-u_e) = 0 \,.\end{split}\]

where \(f\) is defined as follows:

\[\begin{split}f = \nu \omega \,, \\[2mm] \omega = \left[0, \alpha \frac{R_0 - 4R}{a R_0 R} - \beta \frac{B_p}{B_0}\frac{R_0^2}{a R^3}, 0 \right] \,, \\[2mm] R = \sqrt{x^2 + y^2} \,.\end{split}\]

Can only be defined in Cartesian coordinates. The solution is given by:

\[\begin{split}\phi = \frac{1}{2} a B_0 \alpha \left( \frac{(R-R_0)^2+z^2}{a^2} - \frac{2}{3} \right) \\[2mm] R = \sqrt{x^2 + y^2} \,.\end{split}\]
Parameters:
  • a (float) – Minor radius of torus (default: 1.).

  • R0 (float) – Major radius of torus (default: 2.).

  • B0 (float) – On-axis (r=0) toroidal magnetic field (default: 10.).

  • Bp (float) – Poloidal magnetic field (default: 12.5).

  • alpha (float) – (default: 0.1)

  • beta (float) – (default: 1.0)

References

[1] Juan Vicente Gutiérrez-Santacreu, Omar Maj, Marco Restelli: Finite element discretization of a Stokes-like model arising in plasma physics, Journal of Computational Physics 2018.

class struphy.initial.perturbations.ManufacturedSolutionVelocity(species='Ions', dimension='1D', b0=1.0, comp: int = 0)[source]#

Bases: Perturbation

Analytic solutions \(u\) and \(u_e\) of the system:

\[\begin{split}\partial_t u = - \nabla \phi + u \times B + \nu \Delta u + f \,,\\ 0 = \nabla \phi- u_e \times B + \nu_e \Delta u_e + f_e \,, \\ \nabla \cdot (u-u_e) = 0 \,.\end{split}\]

Can only be defined in Cartesian coordinates. The solution in 1D is given by:

\[\begin{split}u = \left[\begin{array}{c} sin(2 \pi x) + 1.0 \\ 0 \\ 0 \end{array} \right] \,, u_e = \left[\begin{array}{c} sin(2 \pi x) \\ 0 \\ 0 \end{array} \right] \,.\end{split}\]

The solution in 2D is given by:

\[\begin{split}u = \left[\begin{array}{c} -sin(2 \pi x) sin(2 \pi y) \\ -cos(2 \pi y) cos(2 \pi y) \\ 0 \end{array} \right] \,, u_e = \left[\begin{array}{c} -sin(4 \pi x) sin(4 \pi y) \\ -cos(4 \pi y) cos(4 \pi y) \\ 0 \end{array} \right] \,.\end{split}\]
Parameters:
  • species (string) – ‘Ions’ or ‘Electrons’.

  • comp (int) – Which component of the solution (‘0’, ‘1’ or ‘2’).

  • dimension (string) – Defines the manufactured solution to be selected (‘1D’ or ‘2D’).

  • b0 (float) – Magnetic field (default: 1.0).

  • comp – Which component (0, 1 or 2) of vector is perturbed (=0 for scalar-valued functions)

class struphy.initial.perturbations.ManufacturedSolutionPotential(dimension='1D', b0=1.0)[source]#

Bases: Perturbation

Analytic solution \(\phi\) of the system:

\[\begin{split}\partial_t u = - \nabla \phi + u \times B + \nu \Delta u + f \,,\\ 0 = \nabla \phi- u_e \times B + \nu_e \Delta u_e + f_e \,, \\ \nabla \cdot (u-u_e) = 0 \,.\end{split}\]

where \(f\) is defined as follows:

\[\begin{split}f = \left[1 - b_0 cos(x) - \nu sin(y), 1 - b_0 sin(y) + \nu cos(x) , 0 \right] \,, \\[2mm] f_e = \left[-1 + 0.5 b_0 cos(x) - \nu_e 0.5 sin(y), -1 + 0.5 b_0 sin(y) + \nu_e cos(x) , 0 \right] \,.\end{split}\]

Can only be defined in Cartesian coordinates. The solution in 1D is given by:

\[\phi = sin(2\pi x) \,.\]

The solution in 2D is given by:

\[\phi = cos(2\pi x) + sin(2\pi y) \,.\]
Parameters:
  • dimension (string) – Defines the manufactured solution to be selected (‘1D’ or ‘2D’).

  • b0 (float) – Magnetic field (default: 1.0).

class struphy.initial.perturbations.ManufacturedSolutionVelocity_2(species='Ions', dimension='1D', b0=1.0, comp: int = 0)[source]#

Bases: Perturbation

Analytic solutions \(u\) and \(u_e\) of the system:

\[\begin{split}\partial_t u = - \nabla \phi + u \times B + \nu \Delta u + f \,,\\ 0 = \nabla \phi- u_e \times B + \nu_e \Delta u_e + f_e \,, \\ \nabla \cdot (u-u_e) = 0 \,.\end{split}\]

Can only be defined in Cartesian coordinates. The solution in 1D is given by:

\[\begin{split}u = \left[\begin{array}{c} sin(2 \pi x) + 1.0 \\ 0 \\ 0 \end{array} \right] \,, u_e = \left[\begin{array}{c} sin(2 \pi x) \\ 0 \\ 0 \end{array} \right] \,.\end{split}\]

The solution in 2D is given by:

\[\begin{split}u = \left[\begin{array}{c} -sin(2 \pi x) sin(2 \pi y) \\ -cos(2 \pi y) cos(2 \pi y) \\ 0 \end{array} \right] \,, u_e = \left[\begin{array}{c} -sin(4 \pi x) sin(4 \pi y) \\ -cos(4 \pi y) cos(4 \pi y) \\ 0 \end{array} \right] \,.\end{split}\]
Parameters:
  • species (string) – ‘Ions’ or ‘Electrons’.

  • dimension (string) – Defines the manufactured solution to be selected (‘1D’ or ‘2D’).

  • b0 (float) – Magnetic field (default: 1.0).

  • comp (int) – Which component (0, 1 or 2) of vector is perturbed (=0 for scalar-valued functions)

class struphy.initial.perturbations.ITPA_density(n0: float = 0.00720655, c: tuple = (0.49123, 0.298228, 0.198739, 0.521298), given_in_basis: Literal['0', '1', '2', '3', 'v', 'physical', 'physical_at_eta', 'norm', None] = '0', comp: int = 0)[source]#

Bases: Perturbation

ITPA radial density profile in A. Könies et al. 2018

\[n(\eta_1) = n_0*c_3\exp\left[-\frac{c_2}{c_1}\tanh\left(\frac{\eta_1 - c_0}{c_2}\right)\right]\,.\]
class struphy.initial.perturbations.TokamakManufacturedSolutionVelocity(comp=0, a=1.0, R0=2.0, B0=10.0, Bp=12.5, alpha=0.1, beta=1.0)[source]#

Bases: Perturbation

Analytic solution \(u=u_e\) of the system:

\[\begin{split}\partial_t u = - \nabla \phi + u \times B + \nu \Delta u + f \,,\\ 0 = \nabla \phi- u_e \times B + \nu_e \Delta u_e + f_e \,, \\ \nabla \cdot (u-u_e) = 0 \,.\end{split}\]

where \(f\) is defined as follows:

\[\begin{split}f = \left[\begin{array}{c} \alpha \frac{B_0}{a}(R-R_0) - \alpha \frac{1}{a R_0} \frac{R_0 B_0 Z}{R} + \nu \alpha \frac{1}{a R_0} \frac{R_0}{R^2} \\ \alpha \frac{1}{a R_0} (R-R_0) \frac{R_0 B_0}{R} + \alpha \frac{B_0Z}{a} \\ \alpha \frac{1}{a R_0} \frac{R_0 B_p}{a R^2} \left( (R-R_0)^2 + Z^2\right) \end{array} \right] \,, \\[2mm] f = \left[\begin{array}{c} -\alpha \frac{B_0}{a}(R-R_0) + \alpha \frac{1}{a R_0} \frac{R_0 B_0 Z}{R} + \nu_e \alpha \frac{1}{a R_0} \frac{R_0}{R^2} \\ -\alpha \frac{1}{a R_0} (R-R_0) \frac{R_0 B_0}{R} - \alpha \frac{B_0 Z}{a} \\ -\alpha \frac{1}{a R_0} \frac{ R_0 B_p}{a R^2} \left( (R-R_0)^2 + Z^2\right) \end{array} \right] \,, \\[2mm] R = \sqrt{x^2 + y^2} \,.\end{split}\]

Can only be defined in Cartesian coordinates. The solution is given by:

\[\begin{split}\mathbf{u} = \alpha \frac{1}{a R_0} \left[\begin{array}{c} R-R_0 \\ z \\ 0 \end{array} \right] \,, \\[2mm] R = \sqrt{x^2 + y^2} \,.\end{split}\]
Parameters:
  • comp (string) – Which component of the solution (‘0’, ‘1’ or ‘2’).

  • a (float) – Minor radius of torus (default: 1.).

  • R0 (float) – Major radius of torus (default: 2.).

  • B0 (float) – On-axis (r=0) toroidal magnetic field (default: 10.).

  • Bp (float) – Poloidal magnetic field (default: 12.5).

  • alpha (float) – (default: 0.1)

  • beta (float) – (default: 1.0)

References

[1] Juan Vicente Gutiérrez-Santacreu, Omar Maj, Marco Restelli: Finite element discretization of a Stokes-like model arising in plasma physics, Journal of Computational Physics 2018.

class struphy.initial.perturbations.TokamakManufacturedSolutionVelocity_1(comp=0, a=1.0, R0=2.0, B0=10.0, Bp=12.5, alpha=0.1, beta=1.0)[source]#

Bases: Perturbation

Analytic solution \(u=u_e\) of the system:

\[\begin{split}\partial_t u = - \nabla \phi + u \times B + \nu \Delta u + f \,,\\ 0 = \nabla \phi- u_e \times B + \nu_e \Delta u_e + f_e \,, \\ \nabla \cdot (u-u_e) = 0 \,.\end{split}\]

where \(f\) is defined as follows:

\[\begin{split}f = \left[\begin{array}{c} \alpha \frac{B_0}{a}(R-R_0) - \alpha \frac{1}{a R_0} \frac{R_0 B_0 Z}{R} + \nu \alpha \frac{1}{a R_0} \frac{R_0}{R^2} \\ \alpha \frac{1}{a R_0} (R-R_0) \frac{R_0 B_0}{R} + \alpha \frac{B_0Z}{a} \\ \alpha \frac{1}{a R_0} \frac{R_0 B_p}{a R^2} \left( (R-R_0)^2 + Z^2\right) \end{array} \right] \,, \\[2mm] f = \left[\begin{array}{c} -\alpha \frac{B_0}{a}(R-R_0) + \alpha \frac{1}{a R_0} \frac{R_0 B_0 Z}{R} + \nu_e \alpha \frac{1}{a R_0} \frac{R_0}{R^2} \\ -\alpha \frac{1}{a R_0} (R-R_0) \frac{R_0 B_0}{R} - \alpha \frac{B_0 Z}{a} \\ -\alpha \frac{1}{a R_0} \frac{ R_0 B_p}{a R^2} \left( (R-R_0)^2 + Z^2\right) \end{array} \right] \,, \\[2mm] R = \sqrt{x^2 + y^2} \,.\end{split}\]

Can only be defined in Cartesian coordinates. The solution is given by:

\[\begin{split}\mathbf{u} = \alpha \frac{1}{a R_0} \left[\begin{array}{c} R-R_0 \\ z \\ 0 \end{array} \right] \,, \\[2mm] R = \sqrt{x^2 + y^2} \,.\end{split}\]
Parameters:
  • comp (string) – Which component of the solution (‘0’, ‘1’ or ‘2’).

  • a (float) – Minor radius of torus (default: 1.).

  • R0 (float) – Major radius of torus (default: 2.).

  • B0 (float) – On-axis (r=0) toroidal magnetic field (default: 10.).

  • Bp (float) – Poloidal magnetic field (default: 12.5).

  • alpha (float) – (default: 0.1)

  • beta (float) – (default: 1.0)

References

[1] Juan Vicente Gutiérrez-Santacreu, Omar Maj, Marco Restelli: Finite element discretization of a Stokes-like model arising in plasma physics, Journal of Computational Physics 2018.

class struphy.initial.perturbations.TokamakManufacturedSolutionVelocity_2(comp=0, a=1.0, R0=2.0, B0=10.0, Bp=12.5, alpha=0.1, beta=1.0)[source]#

Bases: Perturbation

Analytic solution \(u=u_e\) of the system:

\[\begin{split}\partial_t u = - \nabla \phi + u \times B + \nu \Delta u + f \,,\\ 0 = \nabla \phi- u_e \times B + \nu_e \Delta u_e + f_e \,, \\ \nabla \cdot (u-u_e) = 0 \,.\end{split}\]

where \(f\) is defined as follows:

\[\begin{split}f = \left[\begin{array}{c} \alpha \frac{B_0}{a}(R-R_0) - \alpha \frac{1}{a R_0} \frac{R_0 B_0 Z}{R} + \nu \alpha \frac{1}{a R_0} \frac{R_0}{R^2} \\ \alpha \frac{1}{a R_0} (R-R_0) \frac{R_0 B_0}{R} + \alpha \frac{B_0Z}{a} \\ \alpha \frac{1}{a R_0} \frac{R_0 B_p}{a R^2} \left( (R-R_0)^2 + Z^2\right) \end{array} \right] \,, \\[2mm] f = \left[\begin{array}{c} -\alpha \frac{B_0}{a}(R-R_0) + \alpha \frac{1}{a R_0} \frac{R_0 B_0 Z}{R} + \nu_e \alpha \frac{1}{a R_0} \frac{R_0}{R^2} \\ -\alpha \frac{1}{a R_0} (R-R_0) \frac{R_0 B_0}{R} - \alpha \frac{B_0 Z}{a} \\ -\alpha \frac{1}{a R_0} \frac{ R_0 B_p}{a R^2} \left( (R-R_0)^2 + Z^2\right) \end{array} \right] \,, \\[2mm] R = \sqrt{x^2 + y^2} \,.\end{split}\]

Can only be defined in Cartesian coordinates. The solution is given by:

\[\begin{split}\mathbf{u} = \alpha \frac{1}{a R_0} \left[\begin{array}{c} R-R_0 \\ z \\ 0 \end{array} \right] \,, \\[2mm] R = \sqrt{x^2 + y^2} \,.\end{split}\]
Parameters:
  • comp (string) – Which component of the solution (‘0’, ‘1’ or ‘2’).

  • a (float) – Minor radius of torus (default: 1.).

  • R0 (float) – Major radius of torus (default: 2.).

  • B0 (float) – On-axis (r=0) toroidal magnetic field (default: 10.).

  • Bp (float) – Poloidal magnetic field (default: 12.5).

  • alpha (float) – (default: 0.1)

  • beta (float) – (default: 1.0)

References

[1] Juan Vicente Gutiérrez-Santacreu, Omar Maj, Marco Restelli: Finite element discretization of a Stokes-like model arising in plasma physics, Journal of Computational Physics 2018.