This repository contains FORTRAN modules that reads the SPEC input and computes the magnetic field and metrics.
Note: the code is only tested in stellarator symmetric cases currently.
Please see the following two links for references.
For magnetic field representation: matrix.pdf
For geometry representation: coords.pdf
- Compile and include all the modules, declare a type(state) to carry the information from SPEC output.
use spec_state
use spec_field
use spec_geometry
use spec_io
type(state) :: ss
- Read the SPEC output, the .sp.h5 file and the .sp.A file. For example:
call read_spec_h5('G3V02L1Fi.001.sp.h5',ss)
call read_spec_field('.G3V02L1Fi.001.sp.A',ss)
- Compute the field or metrics at a desired location (s, theta, xi).
integer :: lvol
real :: s, theta, xi
real :: a(3), gb(3), dgb(3,3)
real :: jac, djac(3), x(3), gij(3,3), dgij(3,3,3)
lvol = 2 ! in volume 2
s = -0.3
theta = 0.7
xi = 2.3
call get_spec_field(ss%A(lvol), ss%lrad(lvol), s, theta, xi, a, gb, dgb)
call get_spec_coord(ss%Ri, lvol, ss%mn, s, theta, xi, jac, djac, x, gij, dgij)
Please note that the output "gb" has three components, and it is actually
The test example "G3V02L1Fi.001" is an elliptic stellarator case (fixed-boundary), one of the standard test cases of SPEC. The case has two inner volumes. The outside boundary of the plasma is shown in the figure below, while the Poincare cross section at