コード例 #1
0
def main():
    integrators = '_'.join([intr.__name__[:2] for intr in args.integrators])

    if not args.filename:
        subst = (args.centralmass.number, args.orbitmass.number,
                 args.mdot.number, args.sma.number, args.interval.number,
                 args.endtime.number, args.datapoints, integrators)
        name = 'binaries_M{}_m{}_mdot{}_s{}_i{}_t{}_p{}_{}.hdf5'.format(*subst)
        filename = args.directory + name
    else:
        filename = args.filename

    with HDF5HandlerAmuse(filename) as datahandler:
        eccentricities = numpy.arange(0, 1, 0.1)
        commit = subprocess.check_output(["git", "rev-parse", "HEAD"])

        datahandler.file.attrs['commit'] = commit
        datahandler.file.attrs['eccentricities'] = str(eccentricities)
        datahandler.file.attrs['M'] = str(args.centralmass)
        datahandler.file.attrs['m'] = str(args.orbitmass)
        datahandler.file.attrs['mdot'] = str(args.mdot)
        datahandler.file.attrs['sma'] = str(args.sma)
        datahandler.file.attrs['interval'] = str(args.interval)
        datahandler.file.attrs['endtime'] = str(args.endtime)
        datahandler.file.attrs['datapoints'] = args.datapoints
        datahandler.file.attrs['integrators'] = integrators

        simulations(datahandler, eccentricities)
コード例 #2
0
def append_scalarquantities():
    filename = 'test.hdf5'

    ones = numpy.ones(10000) |units.kg

    with HDF5HandlerAmuse(filename) as h:
        for sq in ones:
            h.append(sq, 'ones')

    f = h5py.File(filename)
    print(f['ones'], f['ones'].attrs['unit'])
    os.remove(filename)
コード例 #3
0
def append_vectorquantities():
    filename = 'test.hdf5'

    ones = numpy.ones(10000*2).reshape(10000,2) |units.kg

    with HDF5HandlerAmuse(filename) as h:
        for vq in ones:
            h.append(vq, 'ones')

    f = h5py.File(filename)
    print(f['ones'], f['ones'].attrs['unit'])
    os.remove(filename)
コード例 #4
0
def main():
    integrators = '_'.join([intr.__name__[:2] for intr in args.integrators])

    assert args.mdot * args.endtime < args.centralmass

    if args.logspace:
        space = 'logspace'
        timesteps = numpy.logspace(*args.timesteps) | units.yr
    elif args.linspace:
        space = 'linspace'
        timesteps = numpy.linspace(*args.timesteps) | units.yr
    else:
        space = 'arange'
        timesteps = numpy.arange(*args.timesteps) | units.yr

    if not args.filename:
        spacing = "_".join([str(i) for i in args.timesteps])
        subst = (args.centralmass.number, args.orbitmass.number,
                 args.mdot.number, args.smainner.number, spacing, space,
                 args.endtime.number, args.datapoints, integrators)
        name = 'multiplanet_M{}_m{}_mdot{}_sma_in{}__i{}_{}_t{}_p{}_{}.hdf5'.format(
            *subst)
        filename = args.directory + name
    else:
        filename = args.filename

    with HDF5HandlerAmuse(filename) as datahandler:
        commit = subprocess.check_output(["git", "rev-parse", "HEAD"])

        datahandler.file.attrs['commit'] = commit
        datahandler.file.attrs['M'] = str(args.centralmass)
        datahandler.file.attrs['m'] = str(args.orbitmass)
        datahandler.file.attrs['mdot'] = str(args.mdot)
        datahandler.file.attrs['sma'] = str(args.smainner)
        datahandler.file.attrs['space'] = space
        datahandler.file.attrs['timesteps'] = spacing
        datahandler.file.attrs['endtime'] = str(args.endtime)
        datahandler.file.attrs['datapoints'] = args.datapoints
        datahandler.file.attrs['integrators'] = integrators

        simulations(datahandler, timesteps)
コード例 #5
0
def main():
    """
    Simulates a binary system with linear massloss.

    Writes data to hdf5 using the following structure:

    /
    ├── system_00
    │   ├── sequence_00
    │   │   ├── CM_position
    │   │   ├── CM_velocity
    │   │   ├── kinetic_energy
    │   │   ├── mass
    │   │   ├── position
    │   │   ├── potential_energy
    │   │   ├── total_energy
    │   │   └── velocity
    │   ├── sequence_01
    │   ├── sequence_02
    │   └── sequence_03
    ├── system_01
    ├── system_02
    └── system_03

    """
    #TODO: lose all initial parameters such as M,m,o,seperation, t. Replace by mass-loss index.
    M = args.maxmass
    m = args.minmass
    o = args.orbitmass
    seperation = args.seperation
    t = args.deltat
    res = args.resolution
    step = args.stepsize | u.day

    assert M > m

    init_twobodies = [
        twobodies_circular(i | u.MSun, o | u.MSun, seperation | u.AU)
        for i in range(m, M)
    ]

    with HDF5HandlerAmuse(args.filename) as datahandler:

        for syscount, bodies in enumerate(init_twobodies):
            sys_str = "system_" + str(syscount).zfill(2)

            masslosstimes = (numpy.linspace(0.1, t, res)) * bodies[0].period0

            for seqcount, time in enumerate(masslosstimes):
                seq_str = "sequence_" + str(seqcount).zfill(2)
                h5path = "/" + sys_str + "/" + seq_str + "/"
                datahandler.prefix = h5path

                mass_seq, time_seq = massloss_evolution(time,
                                                        bodies[0].mass,
                                                        step=step)

                print(h5path, time.in_(u.yr),
                      "totalsteps {}".format(len(mass_seq)))

                evolve_system_with_massloss(bodies, mass_seq, time_seq,
                                            datahandler)

                datahandler.file.flush()