Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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