Skip to content

Commit

Permalink
Add automated test
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiLehe committed Oct 23, 2024
1 parent d312cde commit d0aa6b0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions openpmd_viewer/addons/pic/lpa_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ def get_laser_envelope( self, t=None, iteration=None, pol=None,

def get_electromagnetic_energy( self, t=None, iteration=None ):
"""
Compute the total electromagnetic energy inside the box (in Joules), i.e.
Compute the total electromagnetic energy inside the box, i.e.
.. math::
Expand All @@ -702,7 +702,7 @@ def get_electromagnetic_energy( self, t=None, iteration=None ):
--------
A float with the total electromagnetic energy inside the box (in Joules)
"""
# Get field array in full 3D
# For RZ: use `theta=None` to get the full 3D field
Ex, info = self.get_field('E', 'x', t=t, iteration=iteration, theta=None )
Ey, info = self.get_field('E', 'y', m=1, iteration=iteration, theta=None )
Ez, info = self.get_field('E', 'z', m=1, iteration=iteration, theta=None )
Expand All @@ -711,7 +711,7 @@ def get_electromagnetic_energy( self, t=None, iteration=None ):
Bz, info = self.get_field('B', 'z', m=1, iteration=iteration, theta=None )

# Compute the energy
energy_density = epsilon_0/2.*(Ex**2 + Ey**2 + Ez**2) + 1./(2*mu_0)*(Bx**2 + By**2 + Bz**2)
energy_density = const.epsilon_0/2.*(Ex**2 + Ey**2 + Ez**2) + 1./(2*const.mu_0)*(Bx**2 + By**2 + Bz**2)
volume = info.dx*info.dy*info.dz # Cell volume
E = (energy_density*volume).sum()
return E
Expand Down

0 comments on commit d0aa6b0

Please sign in to comment.