Skip to content

Commit 5d57ae9

Browse files
committed
Added option to not estimate eps
1 parent 15dfe3d commit 5d57ae9

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

calc_velocity.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
import glob
2020
import gc
2121

22-
def v_xy(f, param, changbin=None, nr=50, min_per_bin=100, changa_preset=None, max_particles=None):
22+
def v_xy(f, param, changbin=None, nr=50, min_per_bin=100, changa_preset=None, \
23+
max_particles=None, est_eps=True):
2324
"""
2425
Attempts to calculate the circular velocities for particles in a thin
2526
(not flat) keplerian disk. Also estimates gravitational softening (eps)
26-
for the gas particles.
27+
for the gas particles
2728
2829
Requires ChaNGa
2930
@@ -52,6 +53,9 @@ def v_xy(f, param, changbin=None, nr=50, min_per_bin=100, changa_preset=None, ma
5253
accelerations and velocities. Setting a smaller number can speed up
5354
computation and save on memory but can yield noisier results.
5455
If None, max is unlimited.
56+
est_eps : bool
57+
Estimate eps (gravitational softening length). Default is True.
58+
If False, it is assumed eps has already been estimated
5559
5660
**RETURNS**
5761
@@ -77,6 +81,10 @@ def v_xy(f, param, changbin=None, nr=50, min_per_bin=100, changa_preset=None, ma
7781
m_scale = float(n_gas)/float(max_particles)
7882
f.g['mass'] *= m_scale
7983

84+
if not est_eps:
85+
86+
f.g['eps'] *= m_scale**(1.0/3)
87+
8088
# Load stuff from the snapshot
8189
r = f.g['rxy'].astype(np.float32)
8290

@@ -118,7 +126,7 @@ def v_xy(f, param, changbin=None, nr=50, min_per_bin=100, changa_preset=None, ma
118126
p = ICgen_utils.changa_run(command)
119127
p.wait()
120128

121-
if iGrav == 0:
129+
if (iGrav == 0) and est_eps:
122130
# Estimate the gravitational softening length on the first iteration
123131
smoothlength_file = f_prefix + '.000000.smoothlength'
124132
eps = ICgen_utils.est_eps(smoothlength_file)

0 commit comments

Comments
 (0)