Skip to content

Commit

Permalink
fix #12 use lume standard method name, write_initial_particles() (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
moellep authored Apr 29, 2024
1 parent 14c1eb2 commit fd46f25
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
7 changes: 4 additions & 3 deletions rslume/elegant.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ def load_output(self):
# TODO(pjm): load other sdds output files
# TODO(pjm): load warnings and errors from log

# -- RS addition

def set_particle_input(self, particle_group, filename="in.sdds"):
def write_initial_particles(self, filename="in.sdds"):
particle_group = self.initial_particles
if not particle_group:
return
filepath = os.path.join(self.workdir, filename)
pmd_beamphysics.interfaces.elegant.write_elegant(
particle_group,
Expand Down
13 changes: 9 additions & 4 deletions rslume/genesis2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class Genesis2(genesis.genesis2.Genesis2):

# override lume-genesis final_particles()
# override lume-genesis final_particles() and write_input()

def final_particles(self):
# compute required wavelengths to hold the whole beam and center at 0
Expand All @@ -33,9 +33,10 @@ def final_particles(self):
v.t -= numpy.mean(v.t)
return v

# -- RS addition

def set_particle_input(self, particle_group, filename="inpart.dat"):
def write_initial_particles(self, filename="inpart.dat"):
particle_group = self.initial_particles
if not particle_group:
return
filepath = os.path.join(self.workdir, filename)

# gamma
Expand Down Expand Up @@ -71,3 +72,7 @@ def set_particle_input(self, particle_group, filename="inpart.dat"):

with open(filepath, "wb") as f:
d.tofile(f)

def write_input(self):
self.write_initial_particles()
super().write_input()
7 changes: 4 additions & 3 deletions rslume/opal.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ def load_output(self):
),
)

# -- RS addition

def set_particle_input(self, particle_group, filename="in.dat"):
def write_initial_particles(self, filename="in.dat"):
particle_group = self.initial_particles
if not particle_group:
return
filepath = os.path.join(self.workdir, filename)
pmd_beamphysics.interfaces.opal.write_opal(
particle_group,
Expand Down
1 change: 1 addition & 0 deletions rslume/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def plot(self):
raise NotImplementedError("plot() not yet implemented.")

def write_input(self):
self.write_initial_particles()
self._input.write_files(self.path)

# Sirepo lattice and command accessors
Expand Down

0 comments on commit fd46f25

Please sign in to comment.