diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..c18dd8d83ceed1806b50b0aaa46beb7e335fff13 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/ diff --git a/nbody6_quick_guide.md b/nbody6_quick_guide.md index f63d1d418c42bae94d72ce91c067670875956b84..9d125d79730a51889e18a43bc18b1dfef44e2814 100644 --- a/nbody6_quick_guide.md +++ b/nbody6_quick_guide.md @@ -22,7 +22,8 @@ To run a simulation we must pass the config file to the executable of nbody6++. Based on the input configuration this file will run until it gets terminated (by the code or by you). -### Reading out the +### Reading out the data: +As Nbody6 outputs the data as fortran binaries, we first need to diff --git a/python_scripts_for_nbody6/__pycache__/config_defaults.cpython-36.pyc b/python_scripts_for_nbody6/__pycache__/config_defaults.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cb46966662e1afb717f4457efc3791e2bc0e4636 Binary files /dev/null and b/python_scripts_for_nbody6/__pycache__/config_defaults.cpython-36.pyc differ diff --git a/python_scripts_for_nbody6/config_defaults.py b/python_scripts_for_nbody6/config_defaults.py new file mode 100644 index 0000000000000000000000000000000000000000..2ba4853ef53e3ffd216fc12515dd21c8cfe8ba3c --- /dev/null +++ b/python_scripts_for_nbody6/config_defaults.py @@ -0,0 +1,176 @@ +# David Hendriks 2019 +# default settings/design for config. Values so that it will generate the content of 'samples/N10k_B1k.input' +# 'VARIABLE': { +# 'VALUE': , +# 'HELP': "", +# }, + +defaults= { + ####################################### + 'nbody6': { + 'KSTART': { + 'VALUE': '1', + 'HELP': "Run control index\n=1: new run (construct new model or read from dat.10)\n=2: restart/continuation of a run, needs fort.1\n=3: restart + changes of DTADJ, DELTAT, TADJ, TNEXT, TCRIT, =4: restart + changes of ETAI, ETAR, ETAU, DTMIN, RMIN, NCSMAX\n=5: restart containing the combination of the control index 3 and 4" + }, + 'TCOMP': { + 'VALUE': 1000000.0, + 'HELP': "Maximum wall-clock time in seconds (parallel runs: wall clock)" + }, + 'TCRITP': { + 'VALUE': 1E6, + 'HELP': " Termination time in Myr", + }, + 'isernb': { + 'VALUE': 40, + 'HELP': "For MPI parallel runs: only irregular block sizes larger than this value are executed in parallel mode (dummy variable for single CPU)", + }, + 'iserreg': { + 'VALUE': 40, + 'HELP': "For MPI parallel runs: only regular block sizes larger than this value are executed in parallel mode (dummy variable for single CPU)", + }, + 'iserks': { + 'VALUE': 40, + 'HELP': "For MPI parallel runs: only ks block sizes larger than this value are executed in parallel mode (dummy variable for single CPU)", + }, + }, + ####################################### + 'input': {}, + ####################################### + 'data': { + 'ALPHA': { + 'VALUE': 2.35, + 'HELP': "Power-law index for initial mass function, routine data.F", + }, + 'BODY1': { + 'VALUE': 20.0, + 'HELP': "Maximum particle mass before scaling (based on KZ(20); solar mass unit)", + }, + 'BODYN': { + 'VALUE': 0.08, + 'HELP': "Minimum particle mass before scaling", + }, + 'NBIN0': { + 'VALUE': 5000, + 'HELP': "Number of primordial binaries (need KZ(8)>0)\n– by routine imf2.F using a binary IMF (KZ(20)≥2)\n– by routine binpop.F splitting single stars (KZ(8)>0)\n– by reading subsystems from dat.10 (KZ(22)≥2)", + }, + 'NHI0': { + 'VALUE': 0, + 'HELP': "Number of primordial hierarchical systems (need KZ(18)≥2)", + }, + 'ZMET': { + 'VALUE': 0.001, + 'HELP': "Metal abundance (in range 0.03 - 0.0001)", + }, + 'EPOCH0': { + 'VALUE': 0, + 'HELP': "Evolutionary epoch (in 10E6 yrs)", + }, + 'DTPLOT': { + 'VALUE': 1.0, + 'HELP': "Plotting interval for stellar evolution HRDIAG (N-body units; ≥ DELTAT)", + } + }, + ####################################### + 'setup': { + 'APO': { + 'VALUE': 0, + 'HELP': "if (kz(5)=2):Separation of two Plummer models in N–body units (SEMI = APO/(1 + ECC). (Notice SEMI will be limited between 2.0 and 50.0)\nif (kz(5)=3):Separation between the perturber and Sun in N–body units", + }, + 'ECC': { + 'VALUE': 0, + 'HELP': "if (kz(5)=2):Eccentricity of two-body orbit (ECC ≥0 and ECC < 0.999)\nif (kz(5)=3):Eccentricity of orbit (=1 for parabolic encounter)\nif (kz(5)=4):Eccentricity (ECC > 1: NAME = 1 & 2 free-floating)", + }, + 'N2': { + 'VALUE': 0, + 'HELP': "if (kz(5)=2):Membership of second Plummer model (N2 <= N)", + }, + 'SCALE': { + 'VALUE': 0, + 'HELP': "if (kz(5)=2):Scale factor for the second Plummer model, second cluster will be generated by first Plummer model with X × SCALE and sqrt(V × SCALE)(≥ 0.2 for limiting minimum size)\nPerturber mass scale factor, perturber mass = Center star mass × SCALE (=1 for Msun)", + }, + 'SEMI': { + 'VALUE': 0, + 'HELP': "if (kz(5)=4):Semi-major axis (slightly modified; ignore if ECC > 1)", + }, + 'M1': { + 'VALUE': 0, + 'HELP': "if (kz(5)=4): Mass of first member (in units of mean mass)", + }, + 'M2': { + 'VALUE': 0, + 'HELP': "if (kz(5)=4): Mass of second member (rescaled total mass = 1)", + }, + 'ZMH': { + 'VALUE': 0, + 'HELP': "if (kz(5)≥6) and (kz(24)<0): Mass of single BH (in N-body units)", + }, + 'RCUT': { + 'VALUE': 0, + 'HELP': "if (kz(5)≥6) and (kz(24)<0): Radial cutoff in Zhao cusp distribution (MNRAS, 278, 488)", + }, + }, + ####################################### + 'scale': { + 'Q': { + 'VALUE': 0, + 'HELP': "Virial ratio (routine scale.F; Q=0.5 for equilibrium)", + }, + 'VXROT': { + 'VALUE': 0, + 'HELP': "XY–velocity scaling factor (> 0 for solid-body rotation)", + }, + 'VZROT': { + 'VALUE': 0, + 'HELP': "Z–velocity scaling factor (not used if VXROT = 0)", + }, + 'RTIDE': { + 'VALUE': 0, + 'HELP': "Unscaled tidal radius for KZ(14)=2 and KZ(22)≥2. If not zero, RBAR = RT/RTIDE where RT[pc] is tidal radius calculated from input GMG and RG0", + }, + 'HELP': "", + }, + ####################################### + 'xtrnl0': { + 'HELP': "", + }, + ####################################### + 'binpop': { + 'HELP': "", + }, + ####################################### + 'hipop': { + 'HELP': "", + }, + ####################################### + 'imbhinit': { + 'HELP': "", + }, + ####################################### + 'cloud0': { + 'NCL': { + 'VALUE': 0, + 'HELP': "Number of interstellar clouds", + }, + 'RB2': { + 'VALUE': 1, + 'HELP': "Radius of cloud boundary in pc (square is saved)", + }, + 'VCL': { + 'VALUE': 1, + 'HELP': "Mean cloud velocity in km/sec", + }, + 'SIGMA': { + 'VALUE': 1, + 'HELP': "Velocity dispersion (KZ(13)>1: Gaussian)", + }, + 'CLM': { + 'VALUE': 1, + 'HELP': "Individual cloud masses in solar masses (maximum MCL)", + }, + 'RCL2': { + 'VALUE': 1, + 'HELP': "Half-mass radii of clouds in pc (square is saved)", + }, + 'HELP': "if (kz(13)>0)", + } +} \ No newline at end of file diff --git a/python_scripts_for_nbody6/nbody6_config_generator.py b/python_scripts_for_nbody6/nbody6_config_generator.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..34f6fd377b1e59a273147909fa04aa3bce21cf17 100644 --- a/python_scripts_for_nbody6/nbody6_config_generator.py +++ b/python_scripts_for_nbody6/nbody6_config_generator.py @@ -0,0 +1,72 @@ +#!/usr TODO: put correct + +""" +Script to generate a configuration file for nbody6 +Based on chap 4 of nbody6++_manual.pdf +""" + +# Todo: finish defaults.py: + # Finish input.F entry + # Finish data.F entry + # Finish setup.F entry + # Finish scale.F entry + # Finish xtrnl0.F entry + # Finish binpop.F entry + # Finish hipop.F entry + # Finish imbhinit.F entry + # Finish cloud0.F entry + + # Put help texts at every key like above + # GO through the default values + + +# Todo: we need a way to handle the logic and give some warnings based on the input +# Go through them to get the formatting right + + +import json + + + + + + + +from config_defaults import defaults + +# Make a copy of the defaults +config = defaults.copy() + + +# Override the values of the defaults config +#print(config['nbody6']) + +def print_config(config): + print(json.dumps(config, indent=4)) + + # for key in config.keys(): + # print(key) + + + + +print_config(config) + + +def generate_config(config, outfile): + """ + Function to write the config output to a file. + TODO: Correctly put the logic of the stuff in it. See page 10 of nbody6 manual + """ + + # Write nbody6.F line + # Write input.F line + # Write data.F line + # Write setup.F line + # Write scale.F line + # Write xtrnl0.F line + # Write binpop.F line + # Write hipop.F line + # Write imbhinit.F line + # Write cloud0.F line +