Ejemplo n.º 1
0
import freegs
from freegs import geqdsk
from freegs.equilibrium import refine
from freegs.plotting import plotEquilibrium

# Reading MAST equilibrium, up-down symmetric coils
tokamak = freegs.machine.MAST()

#with open("g014220.00200") as f:
with open("mast.geqdsk") as f:
  eq = geqdsk.read(f, tokamak, show=True)

# Increase resolution by a factor of 2
eq2 = refine(eq)

# Re-solve, keeping the same control points and profiles
freegs.solve(eq2, eq._profiles, eq.control, rtol=1e-6)

# Save to G-EQDSK
with open("mast-highres.geqdsk", "w") as f:
  geqdsk.write(eq2, f)

plotEquilibrium(eq2)

Ejemplo n.º 2
0
#########################################
# Nonlinear solve

freegs.solve(
    eq,  # The equilibrium to adjust
    profiles,  # The toroidal current profile function
    constrain)  # Constraint function to set coil currents

# eq now contains the solution

print("Done!")

print("Plasma current: %e Amps" % (eq.plasmaCurrent()))
print("Plasma pressure on axis: %e Pascals" % (eq.pressure(0.0)))

tokamak.printCurrents()

##############################################
# Save to G-EQDSK file

from freegs import geqdsk

with open("lsn.geqdsk", "w") as f:
    geqdsk.write(eq, f)

##############################################
# Final plot

axis = eq.plot(show=False)
constrain.plot(axis=axis, show=True)