Skip to content
Snippets Groups Projects
Commit 32c473f2 authored by Yngve Levinsen's avatar Yngve Levinsen
Browse files

several changes to the shell script

many more of the options are added
parent 88187254
No related branches found
No related tags found
No related merge requests found
......@@ -2,23 +2,51 @@
import argparse
import os
import subprocess
# This script simply runs TraceWin CLI version.
# Provides a better CLI than going through the manual
# Spelling corrections of commands..
parser = argparse.ArgumentParser(description="Creates a TraceWin batch command")
parser.add_argument('-p', '--project', dest='project',
help="Project file", required=True)
parser.add_argument('-r', dest='run', action='store_const',
help="Run TraceWin (default just print command)", const=True, default=False)
# path_cal
parser.add_argument('-o', '--output', dest='outpath',
help="Path to calculation directory")
# dat_file
parser.add_argument('-l', '--lattice', dest='lattice',
help="Lattice/structure file (.dat) to use")
parser.add_argument('-f', '--freq', dest='frequency',
help="Bunch Frequency of beam 1 [MHz]")
parser.add_argument('-c', '--current', dest='current',
# dst_file
parser.add_argument('--dst_file', dest='dst_file1',
help="Input distribution file of main beam")
parser.add_argument('--dst_file2', dest='dst_file2',
help="Input distribution file of secondary beam")
# current
parser.add_argument('-c', '--current', dest='current1',
help="Beam Current of beam 1 [mA]")
parser.add_argument('-n', '--npart', dest='npart',
parser.add_argument('--current2', dest='current2',
help="Beam Current of beam 2 [mA]")
# nbr_part
parser.add_argument('-np', dest='nbr_part1',
help="Number of particles in beam 1")
parser.add_argument('-e', '--energy', dest='energy',
parser.add_argument('-np2', dest='nbr_part2',
help="Number of particles in beam 2")
# energy
parser.add_argument('-e', '--energy', dest='energy1',
help="Input beam energy for beam 1 [MeV]")
parser.add_argument('-o', '--output', dest='outpath',
help="Path to calculation directory")
parser.add_argument('-r', '--seed', dest='seed',
parser.add_argument('-e2', dest='energy2',
help="Input beam energy for beam 2 [MeV]")
# freq
parser.add_argument('-f', dest='freq1',
help="Bunch Frequency of beam 1 [MHz]")
parser.add_argument('-f2', dest='freq2',
help="Bunch Frequency of beam 2 [MHz]")
parser.add_argument('-s', '--seed', dest='seed',
help="Initial random seed", type=int)
args = parser.parse_args()
......@@ -32,14 +60,16 @@ if not os.path.isfile(args.project):
if args.lattice:
cmd.append("dat_file="+args.lattice)
if args.frequency:
cmd.append("freq1="+args.lattice)
if args.current:
cmd.append("current1="+args.current)
if args.npart:
cmd.append("npart1="+args.npart)
if args.energy:
cmd.append("energy1="+args.energy)
for arg in ['dst_file1', 'dst_file2',
'current1', 'current2',
'nbr_part1', 'nbr_part2',
'energy1', 'energy2',
'freq1', 'freq2']:
attr=getattr(args,arg)
if attr:
cmd.append(arg+"="+attr)
if args.outpath:
if not os.path.isdir(args.outpath):
print "WARNING: output directory does not exist, creating.."
......@@ -48,5 +78,8 @@ if args.outpath:
if args.seed:
cmd.append("random_seed="+str(args.seed))
# For now we just print the command:
print ' '.join(cmd)
print args.run
if args.run:
subprocess.call(cmd)
else:
print ' '.join(cmd)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment