forge.greens
Green’s functions for the Grad-Shafranov equation.
The Greens function is based on the equivalent function in
gradshafranov.py from FreeGS (https://github.com/freegs-plasma/freegs).
Modified for FORGE to produce Wb instead of Wb/rad. All other functions
in this module are original to FORGE.
Copyright 2016 Ben Dudson, University of York. Email: benjamin.dudson@york.ac.uk Copyright 2025-2026 Chris Marsden
This file is part of FORGE.
FORGE is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
FORGE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with FORGE. If not, see <http://www.gnu.org/licenses/>.
- forge.greens.Greens(Rc, Zc, R, Z)[source]
Poloidal magnetic flux due to a unit current.
Calculates the poloidal magnetic flux (Wb) at (R,Z) due to a unit current at (Rc,Zc) using Green’s function.
- forge.greens.Greens_dpsi_dR(Rc, Zc, R, Z)[source]
First radial derivative of poloidal magnetic flux due to a unit current.
Calculates the radial first derivative of the poloidal magnetic flux (Wb) at (R,Z) due to a unit current at (Rc,Zc) using Green’s function.
d(psi)/dR = ( (mu0 * R) / u ) * ( ( (w^2/d^2)*E(k^2) ) + K(k^2) )
All intermediate variables are defined above.
- forge.greens.Greens_dpsi_dZ(Rc, Zc, R, Z)[source]
First vertical derivative of poloidal magnetic flux due to a unit current.
Calculates the vertical first derivative of the poloidal magnetic flux (Wb) at (R,Z) due to a unit current at (Rc,Zc) using Green’s function.
d(psi)/dZ = ( (mu0 * h) / u ) * ( K(k^2) - ( (v^2/d^2) * E(k^2) ) )
All intermediate variables are defined above.
- forge.greens.Greens_d2psi_dR2(Rc, Zc, R, Z)[source]
Second radial derivative of poloidal magnetic flux due to a unit current.
Calculates the radial second derivative of the poloidal magnetic flux (Wb) at (R,Z) due to a unit current at (Rc,Zc) using Green’s function.
d^{2}(psi)/dR^{2} = ( mu0 / ( d^{4} * u^{3} ) ) * ( ( x_1 * K(k^2) ) + ( x_2 * E(k^2) ) )
All intermediate variables are defined above.
- forge.greens.Greens_d2psi_dZ2(Rc, Zc, R, Z)[source]
Second vertical derivative of poloidal magnetic flux due to a unit current.
Calculates the vertical second derivative of the poloidal magnetic flux (Wb) at (R,Z) due to a unit current at (Rc,Zc) using Green’s function.
- d^{2}(psi)/dZ^{2} = ( -mu0 / ( d^2 * u^3 ) ) * ( ( v^2 * u^2 - h^2 * ( d^2 + ( ( k^2 * (u^2)^2 ) / d^2 ) ) )
E(k^2) + ( h^2 * v^2 - u^2 * d^2 ) * K(k^2) )
All intermediate variables are defined above.
- forge.greens.Greens_d2psi_dR_dZ(Rc, Zc, R, Z)[source]
Second mixed radial-vertical derivative of poloidal magnetic flux due to a unit current.
Calculates the mixed second derivative of the poloidal magnetic flux (Wb) at (R,Z) due to a unit current at (Rc,Zc) using Green’s function
- d^{2}(psi)/(dRdZ) = ( ( mu0 * h * R ) / ( d^2 * u^3 ) ) * ( ( -( ( 3.0 * u^2 ) + ( ( 4.0 * v^2 * w^2 ) / d^2 ) )
E(k^2) ) + ( w^2 * K(k^2) ) )
All intermediate variables are defined above.
- forge.greens.Greens_Br(Rc, Zc, R, Z)[source]
Calculates the radial magnetic field at (R,Z) due to a unit current at (Rc, Zc).
Br = -(1/2piR) * d(psi)/dZ
- forge.greens.Greens_Bz(Rc, Zc, R, Z)[source]
Calculates the vertical magnetic field at (R,Z) due to a unit current at (Rc, Zc).
Bz = (1/2piR) * d(psi)/dR
- forge.greens.Greens_dBr_dR(Rc, Zc, R, Z)[source]
Calculates the radial derivative of the radial magnetic field at (R,Z) due to a unit current at (Rc,Zc).
d(Br)/dR = (1/2pi) * ( ( (1/R^{2}) * (dpsi/dZ) ) - ( (1/R) * (d^{2}(psi)/dRdZ) ) )
- forge.greens.Greens_dBr_dZ(Rc, Zc, R, Z)[source]
Calculates the vertical derivative of the radial magnetic field at (R,Z) due to a unit current at (Rc,Zc).
d(Br)/dZ = (1/2pi) * (-1/R * ( d^{2}(psi)/dZ^{2} ) )