DESC icon indicating copy to clipboard operation
DESC copied to clipboard

Update `save_mgrid` method variable names

Open dpanici opened this issue 9 months ago • 1 comments

dpanici avatar Feb 10 '25 19:02 dpanici

For the mgrid, I did a cursory check to make sure that the dimension names and variable names that we use match the mgrid example shared by Sam, and it seems that they do, so if there are incorrectly named variables in the mgrid, I am unsure of which ones they are

from desc.coils import FourierXYZCoil,CoilSet
from netCDF4 import Dataset

c = FourierXYZCoil()
cset = CoilSet.linspaced_angular(c)
cset.save_mgrid("desc_mgrid.nc",
                Rmin=9.9,Rmax=10.1,
                Zmin=-0.1,Zmax=0.1,
                nR=10,nZ=10,nphi=10,save_vector_potential=False)

d = Dataset("desc_mgrid.nc")
# check that DESC dataset has the correctly-named keys for dimensions
dim_keys=["stringsize" ,
	"external_coil_groups",
	"dim_00001",
	"external_coils",
	"rad" ,
	"zee","phi"]
for key in dim_keys:
    print(key)
    assert key in d.dimensions.keys()
# check that DESC dataset has correctly-named keys for variables
var_keys=["ir","jz","kp","nfp","nextcur","rmin","zmin","rmax","zmax","coil_group","mgrid_mode","raw_coil_cur","br_001","bp_001","bz_001"]
for key in var_keys:
    print(key)
    assert key in d.variables.keys()

dpanici avatar Mar 24 '25 19:03 dpanici