Skip to content

Commit 2c4db2f

Browse files
authored
Merge pull request #121 from freegs-plasma/R0-geqdsk
Add R0 machine property for GEQDSK output
2 parents 8b838c1 + 1d2d39d commit 2c4db2f

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

freegs/geqdsk.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Writing is relatively straightforward, but reading requires inferring
55
the currents in the PF coils
66
7-
Copyright 2016 Ben Dudson, University of York. Email: [email protected]
7+
Copyright 2016-2025 FreeGS contributors
88
99
This file is part of FreeGS.
1010
@@ -85,7 +85,7 @@ def write(eq, fh, label=None, oxpoints=None, fileformat=geqdsk.write):
8585
zmax = eq.Zmax
8686

8787
fvac = eq.fvac() # Vacuum f = R*Bt
88-
R0 = 1.0 # Reference location
88+
R0 = eq.tokamak.R0 # Reference location
8989

9090
data = {
9191
"nx": nx,
@@ -337,6 +337,9 @@ def q_func(psinorm):
337337
# 1 = plasma boundary
338338
psi_norm = clip((psi - psi_axis) / (psi_bndry - psi_axis), 0.0, 1.1)
339339

340+
# rcentr reference location
341+
machine.R0 = data["rcentr"]
342+
340343
# Create an Equilibrium object
341344
eq = Equilibrium(
342345
tokamak=machine,

freegs/machine.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
License
55
-------
66
7-
Copyright 2016-2019 Ben Dudson, University of York. Email: [email protected]
7+
Copyright 2016-2025 FreeGS contributors.
88
99
This file is part of FreeGS.
1010
@@ -637,15 +637,18 @@ class Machine:
637637
638638
"""
639639

640-
def __init__(self, coils, wall=None, sensors=None, nlimit=500):
640+
def __init__(self, coils, wall=None, sensors=None, nlimit=500, R0=1.0):
641641
"""
642642
coils - A list of coils [(label, Coil|Circuit|Solenoid)]
643643
sensors - A list of sensors
644+
R0 - The major radius to be written to GEQDSK [meters].
645+
By convention EFIT has a value of R0 for each tokamak.
644646
"""
645647

646648
self.coils = coils
647649
self.wall = wall
648650
self.sensors = sensors
651+
self.R0 = R0
649652

650653
self.limit_points_R = None
651654
self.limit_points_Z = None
@@ -1018,7 +1021,8 @@ def DIIID():
10181021
-1.00000e-03,0.00000e+00])
10191022
wall = Wall(R,Z)
10201023

1021-
return Machine(coils,wall=wall)
1024+
# Note: Using same R0 convention as EFIT on DIII-D.
1025+
return Machine(coils, wall=wall, R0=1.6995)
10221026

10231027

10241028
def MAST():

0 commit comments

Comments
 (0)