Exemple #1
0
def s2s(infile, outfile):
    csh_command = "s2s in=" + infile + " out=" + outfile + " times='first';"
    run_csh_command(csh_command, use_v2=True)
    return
Exemple #2
0
def s2a2s(infile, outfile, N):
    csh_command = "snapprint in=" + infile + " options=m,x,y,z,vx,vy,vz | a2s in=- out=" + outfile + " read=mxv N=" + str(
        N) + " Nsink=0 Nsph=0;"
    run_csh_command(csh_command, use_v2=True)
    return
Exemple #3
0
def scale_snapshot(infile, outfile, rscale, vscale, Mscale):
    ''' Scale snapshot by rscale in position, vscale velocity and Mscale mass '''
    csh_command = "snapscale in=" + infile + " out=" + outfile + " rscale=" + str(
        rscale) + " vscale=" + str(vscale) + " mscale=" + str(Mscale) + ";"
    run_csh_command(csh_command, use_v2=True)
    return
Exemple #4
0
def stack_snapshots(infile1, infile2, outfile):
    csh_command = "s2s in=" + infile1 + " in2=" + infile2 + " out=" + outfile + ";"
    run_csh_command(csh_command, use_v2=True)
    return
Exemple #5
0
def scale_snapshot(infile, outfile, rscale, vscale, Mscale):
    csh_command = "s2s in=" + infile + " out=" + outfile + " scale1='" + str(
        rscale) + "," + str(vscale) + "," + str(Mscale) + "';"
    run_csh_command(csh_command, use_v2=True)
    return
Exemple #6
0
def make_single_particle(x, name):
    """ Generate snapshot of single particle """
    np.savetxt('tmp', [np.insert(x, 0, 1)])
    csh_command = "a2s in=tmp out=" + name + " N=1 read=mxv;"
    run_csh_command(csh_command)
Exemple #7
0
def run_under_gravity(input_file,
                      output_file,
                      tstop,
                      pot,
                      potpars=None,
                      potfile=None,
                      epsilon=0.001,
                      kmin=7,
                      kmax=3,
                      logfile=None,
                      fac=0.01,
                      fph=0.01,
                      fpa=0.01,
                      fea=0.01,
                      Grav=1,
                      debug=0,
                      tau_step=0.,
                      threads=16,
                      step=None):
    '''
        Run N-body simulation for time with softening epsilon and max time-step = 2e-kmax
        ADVICE:
            Scaling the simulations by a radial scale (Rscale) and mass scale
            (Mscale) along with a new choice of G sets the velocity scale as
            vscale = sqrt(G Mscale/Rscale) and the time unit tunit =
            sqrt(Rscale^3/G M_scale).
            This can be done with shift_scale_snapshot routine and then passing
            Grav = G.
            Running with tau_step = tunit/2**6 appears to work pretty well.

    '''
    if (pot and (potpars == None and potfile == None)):
        print 'Must pass either potpars or potfile'
    Nlev = kmin - kmax + 1
    if (tau_step == 0.):
        tau_step = 1. / np.power(2., kmax) / np.sqrt(Grav)
    #csh_command='gyrfalcON in='+input_file+" out="+output_file+" tstop="+str(tstop)+" eps="+str(epsilon)+" Nlev="+str(Nlev)+" kmax="+str(kmax)+" fac="+str(fac)+" fph="+str(fph)+" fea="+str(fea)+" fpa="+str(fpa)
    csh_command = 'griffin in=' + input_file + " out=" + output_file + " tstop=" + str(
        tstop) + " eps=" + str(epsilon) + " fea=" + str(fea) + " fpa=" + str(
            fpa) + " tau=" + str(tau_step) + " threads=" + str(threads)
    if (step):
        csh_command += " step=" + str(step)
    else:
        csh_command += " step=0"
    # if(pot):
    #   csh_command+=" accname="+pot
    if (pot):
        csh_command += " acc=" + pot
    if (potpars):
        csh_command += " accpars=" + potpars
    if (potfile):
        csh_command += " accstrg=" + potfile
    # if(potfile):
    #   csh_command+=" accfile="+potfile

    #csh_command+=" Grav="+str(Grav)+" debug="+str(debug)
    csh_command += " Gstd=" + str(Grav) + " Gsnk=" + str(
        Grav) + " debug=" + str(debug)
    if (logfile):
        csh_command += " logfile=" + logfile
    csh_command += " ;"
    run_csh_command(csh_command, use_v2=True)