Skip to content

Commit

Permalink
adjust the mgrid reading file to handle mgrids with potential
Browse files Browse the repository at this point in the history
  • Loading branch information
aaroncbader committed Apr 4, 2024
1 parent de04ed9 commit 157839a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/simsopt/field/mgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ def from_file(cls, filename):
bp_arr = []
bz_arr = []

ar_arr = []
ap_arr = []
az_arr = []

nextcur = mgrid.n_ext_cur
for j in range(nextcur):
idx = '{:03d}'.format(j+1)
Expand All @@ -255,6 +259,27 @@ def from_file(cls, filename):
bp_arr.append(bp)
bz_arr.append(bz)

#check for potential in mgrid file
if 'ar_'+idx in f.variables:
ar = f.variables['ar_'+idx][:]
if mgrid.mode == 'S':
ar_arr.append(ar * mgrid.raw_coil_current[j])

Check warning on line 266 in src/simsopt/field/mgrid.py

View check run for this annotation

Codecov / codecov/patch

src/simsopt/field/mgrid.py#L264-L266

Added lines #L264 - L266 were not covered by tests
else:
ar_arr.append(ar)

Check warning on line 268 in src/simsopt/field/mgrid.py

View check run for this annotation

Codecov / codecov/patch

src/simsopt/field/mgrid.py#L268

Added line #L268 was not covered by tests

if 'ap_'+idx in f.variables:
ap = f.variables['ap_'+idx][:]
if mgrid.mode == 'S':
ap_arr.append(ap * mgrid.raw_coil_current[j])

Check warning on line 273 in src/simsopt/field/mgrid.py

View check run for this annotation

Codecov / codecov/patch

src/simsopt/field/mgrid.py#L271-L273

Added lines #L271 - L273 were not covered by tests
else:
ap_arr.append(ap)

Check warning on line 275 in src/simsopt/field/mgrid.py

View check run for this annotation

Codecov / codecov/patch

src/simsopt/field/mgrid.py#L275

Added line #L275 was not covered by tests
if 'az_'+idx in f.variables:
az = f.variables['az_'+idx][:]
if mgrid.mode == 'S':
az_arr.append(az * mgrid.raw_coil_current[j])

Check warning on line 279 in src/simsopt/field/mgrid.py

View check run for this annotation

Codecov / codecov/patch

src/simsopt/field/mgrid.py#L277-L279

Added lines #L277 - L279 were not covered by tests
else:
az_arr.append(az)

Check warning on line 281 in src/simsopt/field/mgrid.py

View check run for this annotation

Codecov / codecov/patch

src/simsopt/field/mgrid.py#L281

Added line #L281 was not covered by tests

mgrid.br_arr = np.array(br_arr)
mgrid.bp_arr = np.array(bp_arr)
mgrid.bz_arr = np.array(bz_arr)
Expand Down

0 comments on commit 157839a

Please sign in to comment.