From 2ae83a5df2ff6358bd276621cc67110bf1dcd51e Mon Sep 17 00:00:00 2001
From: David Hendriks <davidhendriks93@gmail.com>
Date: Tue, 7 May 2019 19:22:21 +0100
Subject: [PATCH] added gitignore and some scripts

---
 .gitignore                                    |   1 +
 nbody6_quick_guide.md                         |   3 +-
 .../config_defaults.cpython-36.pyc            | Bin 0 -> 4158 bytes
 python_scripts_for_nbody6/config_defaults.py  | 176 ++++++++++++++++++
 .../nbody6_config_generator.py                |  72 +++++++
 5 files changed, 251 insertions(+), 1 deletion(-)
 create mode 100644 .gitignore
 create mode 100644 python_scripts_for_nbody6/__pycache__/config_defaults.cpython-36.pyc
 create mode 100644 python_scripts_for_nbody6/config_defaults.py

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c18dd8d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+__pycache__/
diff --git a/nbody6_quick_guide.md b/nbody6_quick_guide.md
index f63d1d4..9d125d7 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
GIT binary patch
literal 4158
zcmcgv&2t-B5tn64al{5#vcN77Xkc09v9dIhKh|*~C$g;A+V#j<NpX1xDA#D-ll0c}
zp}d)iqv60FwkWu4QN@9auN?LQ7ybjPxbRW69DQRs<px!pC=T>{8p%$agcI1MY0b>*
ze*L<C{p;59wQIS5{^64!{N}Y(>TjtFe=p<ryZ8yV=Ta$}qH{ETnx^w~A(0s+v-C<L
z7ZZ6^$=qp{r|4(sOX}_#{j8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ug=?9ZrS}A=d7Ge`Nm<5QpJKvv?>QXF*wVs^4MXj6&EkcGMp29sMjt
zGG}w|;v6fzL}4nSOp7$St1j`4^B%9-4VJZPGdQnCG<b|uk&1Phbvz1URy~FuvKW=U
z3;{5*u|OU~a^6HA1M4B9B)(xtY)=-?5`l}4-6CQ-)()o0LC_#^2l9u6Z0)6GvWdjE
zV?{y0Ev(GdhDZ5BP9q6A>5@V{4j*Xje9V!<h?@-NMs1J8rCrPEV+~^o3iO@NTvv+E
zbop9Rg3<+@kSpeVv$ki>x3>_L2ly@1Y3vwPbH27`NQCZ{Rs2ZqEbGahw|16MDL7k@
zQ=FLzSQw2^$bvPqk3!)&*j*>%jhR8B_DAL-cY8xQ6Pj6dHoZya&K4=_Tagn6AE(4i
zGEMUGucIP@P84@LrSf`_4t0G^FBMzu{kQA2Zl@TiP8@_0MZ#Me3IBa&hsDu29Qxi-
zU<*D9gCk_sqlv5X2V9>Ij;1>mM&q-^+emJa!#3r1!O!uMp3BZ({^S<Y3zwf>T$#(h
T_`O_vX-zu2ko;$!qn-W_M(`L2

literal 0
HcmV?d00001

diff --git a/python_scripts_for_nbody6/config_defaults.py b/python_scripts_for_nbody6/config_defaults.py
new file mode 100644
index 0000000..2ba4853
--- /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 e69de29..34f6fd3 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
+
-- 
GitLab