Skip to content

Commit

Permalink
Updates for running Windows executables from Linux side with WSL, plu…
Browse files Browse the repository at this point in the history
…s other updates:

 * add note to README about code availability
 * update openpmd_beamphysics requirement
 * interpolate.py: run_cmd include optional t35 filename (needed for WSL)
 * superfish.py: if self.use_container is False, run windows cmd (don't check platform again)
 * writers.py: update deprecated np.complex
 * some comments added to examples about running on WSL or using custom container
  • Loading branch information
NicholasWTaylor committed Apr 17, 2024
1 parent 26a4a19 commit a51e06a
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 236 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ Python tools for Poisson Superfish calculations

https://laacg.lanl.gov

> :warning: As of April 2024, and since at least May 2023, the download site for
Poisson/Superfish is unavailable. Unfortunately, we do not have any information
about when or if it will be made available again. (see https://github.com/ChristopherMayes/PySuperfish/issues/2)

## Native Windows

Download and install Poisson Supefish from:

https://laacg.lanl.gov

*see note above about availability of Poisson/Superfish files.

## Docker

Public (you must provide the executables)
Expand Down
11 changes: 9 additions & 2 deletions examples/T7_fieldmaps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,18 @@
"source": [
"os.remove('TEST.T7')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -359,7 +366,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down
83 changes: 29 additions & 54 deletions examples/fieldmesh.ipynb

Large diffs are not rendered by default.

141 changes: 81 additions & 60 deletions examples/poisson_example.ipynb

Large diffs are not rendered by default.

219 changes: 110 additions & 109 deletions examples/superfish_basic_example.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
numpy
matplotlib
pmd_beamphysics
openpmd_beamphysics
8 changes: 6 additions & 2 deletions superfish/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,13 @@ def interpolate2d(sf,
with open(inifile, 'w') as f:
f.write("""[global]
Force1MVperMeter=No""")

# Needed on WSL, otherwise optional
t35file = sf.basename+'.T35'


# Run
sf.run_cmd('sf7', ifile)
sf.run_cmd('sf7', ifile, t35file)

# Get the filename
t7file = get_t7(sf.path)
Expand Down Expand Up @@ -112,4 +116,4 @@ def interpolate2d(sf,
type = 'magnetic'
d = parse_poisson_t7(t7file, type=type)

return d
return d
10 changes: 5 additions & 5 deletions superfish/superfish.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,17 @@ def windows_run_cmd(self, *args):
return cmd

def run_cmd(self, *cmds, **kwargs):
"""
Runs a command in in self.
r"""
Runs a command in self.
Example:
.run_cmd(['C:\LANL\AUTOMESH.EXE', 'TEST.AM'], timeout=1)
"""
if platform.system() == 'Windows':
cmds = self.windows_run_cmd(*cmds)
else:
if self.use_container:
cmds = self.container_run_cmd(*cmds)
else:
cmds = self.windows_run_cmd(*cmds)

self.vprint(f'Running: {cmds}')

Expand Down
6 changes: 3 additions & 3 deletions superfish/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def fish_externalfield_data(t7data,
Ez0_max = 1

components = {}
components['electricField/r'] = t7data['Er'].reshape(nr, 1, nz).astype(np.complex) * 1e6/Ez0_max
components['electricField/z'] = t7data['Ez'].reshape(nr, 1, nz).astype(np.complex) * 1e6/Ez0_max
components['electricField/r'] = t7data['Er'].reshape(nr, 1, nz).astype(complex) * 1e6/Ez0_max
components['electricField/z'] = t7data['Ez'].reshape(nr, 1, nz).astype(complex) * 1e6/Ez0_max
components['magneticField/theta'] = t7data['Hphi'].reshape(nr, 1, nz) * -1j*mu_0/Ez0_max # -i * mu_0


Expand Down Expand Up @@ -246,4 +246,4 @@ def write_poisson_t7(filename, t7data, fmt='%10.8e'):

np.savetxt(filename, dat, header=header, comments='', fmt = fmt)

return filename
return filename

0 comments on commit a51e06a

Please sign in to comment.