PlasmaControl / DESC

Stellarator Equilibrium and Optimization Suite
MIT License
95 stars 27 forks source link

Question about resizing an equilibrium #1316

Open mohawk811 opened 1 hour ago

mohawk811 commented 1 hour ago

Hello, I was wondering if I could get help on resizing the precise QA equilibria on desc to fit inside a toroidal vacuum vessel (or at least as close as I can fit it) This is the way I have it set up:

`eq = get("precise_QA") grid = LinearGrid(L=eq.L_grid, M=eq.M_grid, N=eq.N_grid, NFP=eq.NFP, rho=np.array([1.0]), sym=True)

Define the major and minor radius

HBT_R0 = 1.0 # Major radius HBT_a = 0.25 # Minor radius

Define the Fourier coefficients for R (radial) and Z (vertical)

In the old code, R_mn = [HBT_R0, HBT_a] corresponds to n=0, m=0 and n=0, m=1 modes

R_lmn = np.array([HBT_R0, HBT_a]) # Coefficients for R (radial direction, cosine modes) Z_lmn = np.array([0.0, HBT_a]) # Coefficients for Z (vertical direction, sine mode for m=1)

Define the mode numbers [m, n] for the Fourier terms

Use positive for cosine modes and negative for sine modes

R uses cosine modes: m=0, n=0 (constant) and m=1, n=0 (cosine term)

Z uses sine modes: m=-1, n=0 for the sine term

modes_R = np.array([[0, 0], [1, 0]]) # Mode numbers for R (cosine modes) modes_Z = np.array([[0, 0], [-1, 0]]) # Mode numbers for Z (sine mode for m=1)

Number of field periods (NFP) and symmetry setting

NFP = 1 # Number of field periods (axisymmetric, so NFP=1) sym = True # Enforce stellarator symmetry

Create the new surface using FourierRZToroidalSurface

surf = FourierRZToroidalSurface( R_lmn=R_lmn, # Radial Fourier coefficients Z_lmn=Z_lmn, # Vertical Fourier coefficients modes_R=modes_R, # Mode numbers for R (cosine modes) modes_Z=modes_Z, # Mode numbers for Z (sine modes for Z) NFP=NFP, # Number of field periods sym=sym, # Stellarator symmetry check_orientation=False # Skip orientation check )

eq = get("precise_QA")

eq = desc.io.load("input.nfp2ginsburg.h5")

Psi = 0.023050438527737336

eq = Equilibrium(L=2, M=2, N=2, Psi=Psi)

eq=desc.compat.rescale(eq=eq, L=('R0',1))

eq=desc.compat.rescale(eq=eq, L=('R0',1))

V = eq.compute('V',grid=grid)['V']

eq = desc.io.load("input.nfp2ginsburg.h5")

Psi = 0.023050438527737336

eq = Equilibrium(L=2, M=2, N=2, Psi=Psi)

eq.solve()

eq=desc.compat.rescale(eq=eq, L=('V',.2))

eq.solve()

eq = desc.examples.get("precise_QA")

V = eq.compute('V',grid=grid)['V']

eq=desc.compat.rescale(eq=eq, L=('R0',.5)) eq=desc.compat.rescale(eq=eq, L=('a',.15)) fig, ax = plt.subplots(figsize=(8, 8)) # Create a figure and axis

Plot the boundary of 'surf' on the same axis

plot_boundary(surf, ax=ax,phi=8) # Pass the 'ax' to plot on the same figure

Plot the boundary of 'eq_out' on the same axis

plot_boundary(eq, ax=ax,phi=8) # Pass the same 'ax'

Display the combined plot

plt.show()`

It seems like the way I have it set up I can only manipulate just one variable at a time. Does anyone have any advice on how to resize this equilibria so that I could have the best intial condition?

mohawk811 commented 1 hour ago
Screenshot 2024-10-22 at 10 31 27 AM
mohawk811 commented 1 hour ago

For reference I want to fit the equilibria in a toroidal boundary