Skip to content

Commit

Permalink
FIX: genesis4 scaling factor
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-lauer committed Dec 17, 2024
1 parent 26b418b commit 657b384
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion docs/examples/wavefront.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@
{
"cell_type": "markdown",
"id": "d3fc2a90-d104-46c3-86fc-c3f33d3be642",
"metadata": {},
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"```\n",
"Wwigner = Wavefront.gaussian_pulse(\n",
Expand Down
3 changes: 2 additions & 1 deletion pmd_beamphysics/wavefront.py
Original file line number Diff line number Diff line change
Expand Up @@ -1894,8 +1894,9 @@ def to_genesis4_fieldfile(self) -> Genesis4FieldFile:
else:
refposition = 0.0

v_over_m_to_genesis = gridsize / np.sqrt(2.0 * Z0)
return FieldFile(
dfl=self.rmesh,
dfl=self.rmesh * v_over_m_to_genesis,
param=FieldFileParams(
# number of gridpoints in one transverse dimension equal to nx and ny above
gridpoints=nx,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_wavefront.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ def test_write_and_read_genesis4(
# E ? ^ ^ ^ ^ ^ ^...
# Should probably switch to `allclose` in `__eq__` but I think Chris has a
# preference for true equality
# assert np.allclose(wavefront.rmesh.real, loaded.rmesh.real)
# assert np.allclose(wavefront.rmesh.imag, loaded.rmesh.imag)
# loaded._rmesh = wavefront.rmesh
# assert wavefront == loaded
assert np.allclose(wavefront.rmesh.real, loaded.rmesh.real)
assert np.allclose(wavefront.rmesh.imag, loaded.rmesh.imag)
loaded._rmesh = wavefront.rmesh
assert wavefront == loaded


def test_write_and_read_openpmd(
Expand Down

0 comments on commit 657b384

Please sign in to comment.