From aae58a9d76e805aef1ca3445bfc97e8715d67e35 Mon Sep 17 00:00:00 2001 From: Josh Borrow <joshua.borrow@durham.ac.uk> Date: Tue, 20 Mar 2018 18:07:00 +0000 Subject: [PATCH] Added ability to select the number of particles in the initial conditions as a runtime parameter --- examples/EvrardCollapse_3D/makeIC.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/examples/EvrardCollapse_3D/makeIC.py b/examples/EvrardCollapse_3D/makeIC.py index b68f0da0e1..f4d3c4c5bf 100644 --- a/examples/EvrardCollapse_3D/makeIC.py +++ b/examples/EvrardCollapse_3D/makeIC.py @@ -18,9 +18,24 @@ ################################################################################ import h5py +import argparse as ap from numpy import * -# Generates a swift IC file for the Evrard collapse +parser = ap.ArgumentParser( + description="Generates a swift IC file for the Evrard collapse" +) + +parser.add_argument( + "-n", + "--nparts", + help=""" + Number of particles to be used in the Evrard collapse. + """, + required=False, + default=100000 +) + +args = vars(parser.parse_args()) # Parameters gamma = 5. / 3. # Gas adiabatic index @@ -28,7 +43,7 @@ M = 1. # total mass of the sphere R = 1. # radius of the sphere u0 = 0.05 / M # initial thermal energy fileName = "evrard.hdf5" -numPart = 100000 +numPart = int(args["nparts"]) r = R * sqrt(random.random(numPart)) phi = 2. * pi * random.random(numPart) -- GitLab