Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
remove unused retry mechanism for beam spectrum script
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed May 20, 2020
1 parent 0df1a15 commit 0251753
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
10 changes: 5 additions & 5 deletions MonoenergeticBeams.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
def main():
signal.signal(signal.SIGINT, signal.SIG_DFL)
p = ArgumentParser(description="parallel Transcar runner")
p.add_argument("rodir", help="root of beam directory to output")
p.add_argument("-Q0", help="Assumed particle flux", type=float, default=70114000000.0)
p.add_argument("outroot", help="root of beam directory to output")
p.add_argument("-Q0", help="total particle flux", type=float, default=70114000000.0)
p.add_argument("-infn", help="energy bin CSV file", default="BT_E1E2prev.csv")
p.add_argument("--msgfn", help="file to write transcar messages to", default="transcar.log")
p.add_argument("--errfn", help="file to write transcar Errors to", default="transcarError.log")
p.add_argument("-msgfn", help="file to write transcar messages to", default="transcar.log")
p.add_argument("-errfn", help="file to write transcar Errors to", default="transcarError.log")
p.add_argument("-np", help="number of concurrent processes", type=int, default=Ncpu)
p = p.parse_args()

rodir = Path(p.rodir).expanduser().resolve()
rodir = Path(p.outroot).expanduser().resolve()
infn = Path(p.infn).expanduser().resolve()

params = {"rodir": rodir, "Q0": p.Q0, "msgfn": p.msgfn, "errfn": p.errfn}
Expand Down
10 changes: 5 additions & 5 deletions SpectrumBeam.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ def main():
signal.signal(signal.SIGINT, signal.SIG_DFL)
p = ArgumentParser(description="parallel instance transcar runner")
p.add_argument("fluxfn", help="particle flux csv filename")
p.add_argument("rodir", help="output directory")
p.add_argument("-Q0", help="Assumed particle flux", type=float, default=70114000000.0)
p.add_argument("outdir", help="simulation output directory")
p.add_argument("-Q0", help="total particle flux", type=float, default=70114000000.0)
p.add_argument("-infn", help="energy bin CSV file", default="BT_E1E2prev.csv")
p.add_argument("-datcar", help="DATCAR input file to copy", default="DATCAR_spectrum.asc")
p.add_argument("--msgfn", help="file to write transcar messages to", default="transcar.log")
p.add_argument("--errfn", help="file to write transcar Errors to", default="transcarError.log")
p.add_argument("-msgfn", help="file to write transcar messages to", default="transcar.log")
p.add_argument("-errfn", help="file to write transcar Errors to", default="transcarError.log")
p = p.parse_args()

rodir = Path(p.rodir).expanduser().resolve()
rodir = Path(p.outdir).expanduser().resolve()
infn = Path(p.infn).expanduser().resolve()
fluxfn = Path(p.fluxfn).expanduser().resolve()

Expand Down
13 changes: 3 additions & 10 deletions transcar/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,16 @@ def beam_spectrum_arbiter(beam: pandas.DataFrame, P: T.Dict[str, T.Any]):
"""
run beam with user-defined flux spectrum
"""
MAX_TRY = 3
odir = P["rodir"]

print("Running Transcar single-threaded.")
print(odir / P["errfn"], "logs the simulation output text, watch this file to see simulation progress.")
print(odir / P["msgfn"], "logs the simulation output text, watch this file to see simulation progress.")

if run_spectrum(beam, P):
print("Transcar finished OK on first try")
print("OK: Transcar complete")
return

for i in range(1, MAX_TRY):
logging.warning(f"Transcar sim retry {i}")
runTranscar(odir, P["errfn"], P["msgfn"])
if transcaroutcheck(odir, P["errfn"]):
return

raise RuntimeError(f"Transcar failed after {MAX_TRY} tries, giving up")
raise RuntimeError(f"Transcar run failed. See {odir / P['errfn']} for clues")


def run_spectrum(beam: pandas.DataFrame, P: T.Dict[str, T.Any]) -> bool:
Expand Down

0 comments on commit 0251753

Please sign in to comment.