def new_instance_of_athena_code(self):
     result = Athena(number_of_workers=self.number_of_workers,
                     **self.hydro_code_options)
     result.initialize_code()
     result.parameters.gamma = self.gamma
     result.parameters.courant_number = 0.3
     return result
Ejemplo n.º 2
0
 def new_instance_of_athena_selfgravity_code(self):
     result=Athena(mode = AthenaInterface.MODE_SELF_GRAVITY, redirection="none", number_of_workers=1)
     result.initialize_code()
     result.parameters.gamma = self.gamma
     result.parameters.courant_number=0.3
     result.set_grav_mean_rho(self.rho_mean.value_in(density))
     return result
 def new_instance_of_athena_code(self):
     result = Athena(number_of_workers=self.number_of_workers,
                     **self.hydro_code_options)
     result.initialize_code()
     result.parameters.gamma = self.gamma
     result.parameters.courant_number = 0.3
     return result
Ejemplo n.º 4
0
 def new_instance_of_athena_code(self):
     from amuse.community.athena.interface import Athena
     result=Athena(number_of_workers=self.number_of_workers, debugger="xterm")
     result.initialize_code()
     result.parameters.gamma = self.gamma
     result.parameters.courant_number=0.8
     print result.define_subgrid(1, 800, 200, 1, 0, 500, 0)
     print result.define_subgrid(1, 800, 200, 1, 0, 100, 0)
     return result
Ejemplo n.º 5
0
 def new_instance_of_athena_code(self):
     from amuse.community.athena.interface import Athena
     result = Athena(
         number_of_workers=self.number_of_workers, debugger="xterm")
     result.initialize_code()
     result.parameters.gamma = self.gamma
     result.parameters.courant_number = 0.8
     print(result.define_subgrid(1, 800, 200, 1, 0, 500, 0))
     print(result.define_subgrid(1, 800, 200, 1, 0, 100, 0))
     return result
Ejemplo n.º 6
0
    def new_instance_of_athena_code(self):
        from amuse.community.athena.interface import Athena
        result=Athena(number_of_workers=self.number_of_workers, redirection="none")
        result.initialize_code()
        result.parameters.gamma = self.gamma
        result.parameters.courant_number=0.3

        result.parameters.x_boundary_conditions = ("reflective","reflective")
        result.parameters.y_boundary_conditions = ("outflow","outflow")
        result.parameters.z_boundary_conditions = ("reflective","reflective")
                
        return result
Ejemplo n.º 7
0
    def new_instance_of_athena_code(self):
        from amuse.community.athena.interface import Athena
        result=Athena(number_of_workers=self.number_of_workers, redirection="none")
        result.initialize_code()
        result.parameters.gamma = self.gamma
        result.parameters.courant_number=0.3

        result.parameters.x_boundary_conditions = ("reflective","reflective")
        result.parameters.y_boundary_conditions = ("outflow","outflow")
        result.parameters.z_boundary_conditions = ("reflective","reflective")
                
        return result
Ejemplo n.º 8
0
    def new_code(self):
        if RUN_WITH_SELF_GRAVITY:
            result = Athena(self.unit_converter, mode='self-gravity')
            result.parameters.gamma = self.gamma
            result.parameters.courant_number = 0.3
            result.parameters.four_pi_G = numpy.pi * 4 * constants.G
            result.parameters.gravity_mean_rho = self.rho0
        else:
            result = Athena(self.unit_converter)
            result.parameters.gamma = self.gamma
            result.parameters.courant_number = 0.3

        return result
Ejemplo n.º 9
0
 def new_instance_of_athena_code(self):
     from amuse.community.athena.interface import Athena
     result = Athena(number_of_workers=self.number_of_workers)
     result.parameters.gamma = self.gamma
     result.parameters.courant_number = 0.4
     self.nghost = 4
     return result
Ejemplo n.º 10
0
 def new_instance_of_athena_and_nbody_code(self):
     gridcode=Athena(redirection="none", number_of_workers=1)
     gridcode.initialize_code()
     gridcode.parameters.gamma = self.gamma
     gridcode.parameters.courant_number=0.3
     
     gridcode.set_has_external_gravitational_potential(1)
     
     nbodycode = PhiGRAPE(mode="gpu")
     #nbodycode = Octgrav(mode="gpu")
     nbodycode.initialize_code()
     nbodycode.parameters.epsilon_squared = (self.size / (10000.0 * self.number_of_grid_points)) ** 2
     nbodycode.commit_parameters()
     
     result = HydroGridAndNbody(gridcode, nbodycode)
     return result
 def new_instance_of_athena_selfgravity_code(self):
     result = Athena(mode=AthenaInterface.MODE_SELF_GRAVITY,
                     redirection="none",
                     number_of_workers=1)
     result.initialize_code()
     result.parameters.gamma = self.gamma
     result.parameters.courant_number = 0.3
     result.set_grav_mean_rho(self.rho_mean)
     return result
    def new_instance_of_athena_and_nbody_code(self):
        gridcode = Athena(redirection="none", number_of_workers=1)
        gridcode.initialize_code()
        gridcode.parameters.gamma = self.gamma
        gridcode.parameters.courant_number = 0.3

        gridcode.set_has_external_gravitational_potential(1)

        nbodycode = PhiGRAPE(mode="gpu")
        #nbodycode = Octgrav(mode="gpu")
        nbodycode.initialize_code()
        nbodycode.parameters.epsilon_squared = (
            self.size / (10000.0 * self.number_of_grid_points))**2
        nbodycode.commit_parameters()

        result = HydroGridAndNbody(gridcode, nbodycode)
        return result
Ejemplo n.º 13
0
 def new_instance_of_athena_code(self):
     result=Athena(redirection="none", number_of_workers=1)
     result.initialize_code()
     result.parameters.gamma = self.gamma
     result.parameters.courant_number=0.3
     return result
Ejemplo n.º 14
0
def new_instance_of_hydro_code(number_of_workers=1):
    result = Athena(number_of_workers=number_of_workers)
    result.parameters.gamma = GAMMA
    result.parameters.courant_number = 0.8
    return result
 def new_instance_of_athena_code(self):
     result = Athena(redirection="none", number_of_workers=1)
     result.initialize_code()
     result.parameters.gamma = self.gamma
     result.parameters.courant_number = 0.3
     return result
Ejemplo n.º 16
0
if __name__ == "__main__":
    number_of_grid_points = 40
    halfway = int((number_of_grid_points - 1) / 2)

    t_end = 1.0 | units.Myr
    n_steps = 100
    dt = t_end / n_steps

    length_unit = 10.0 | units.parsec
    mass_unit = (1.14
                 | units.amu / units.cm**3) * length_unit**3  # ~ total mass
    speed_unit = 1.0 | units.kms

    converter = generic_unit_converter.ConvertBetweenGenericAndSiUnits(
        length_unit, mass_unit, speed_unit)
    hydro_code = Athena(unit_converter=converter,
                        number_of_workers=2)  #,redirection='none')
    hydro_code.initialize_code()

    hydro_code.parameters.gamma = 1.001
    hydro_code.parameters.courant_number = 0.3
    hydro_code.parameters.mesh_size = (number_of_grid_points,
                                       number_of_grid_points,
                                       number_of_grid_points)
    hydro_code.parameters.length_x = 1 | length
    hydro_code.parameters.length_y = 1 | length
    hydro_code.parameters.length_z = 1 | length
    hydro_code.parameters.x_boundary_conditions = ("periodic", "periodic")
    hydro_code.parameters.y_boundary_conditions = ("periodic", "periodic")
    hydro_code.parameters.z_boundary_conditions = ("periodic", "periodic")
    hydro_code.commit_parameters()
Ejemplo n.º 17
0
def hydro_grid_in_potential_well(mass=1 | units.MSun, length=100 | units.AU):
    converter = nbody_system.nbody_to_si(mass, length)

    # calculate density in field based on solar wind
    # gives a very low number
    molar_mass_hydrogen_proton = 1 | units.g / units.mol
    density_hydrogen_in_stellar_wind = 10 | 1 / units.cm**3
    particles_per_mol = 6.022e23 | 1 / units.mol
    density_hydrogen_in_stellar_wind_in_moles = (
        density_hydrogen_in_stellar_wind
        / particles_per_mol
    )
    density_gas = 100 * (
        density_hydrogen_in_stellar_wind_in_moles
        * molar_mass_hydrogen_proton
    ).as_quantity_in(units.MSun / units.AU**3)

    # override with higher number for plotting
    density_gas = 1e-3 | units.MSun / units.AU**3

    instance = Athena(converter)
    instance.initialize_code()
    instance.parameters.nx = 50
    instance.parameters.ny = 50
    instance.parameters.nz = 1
    instance.parameters.length_x = length
    instance.parameters.length_y = length
    instance.parameters.length_z = length
    instance.parameters.x_boundary_conditions = ("periodic", "periodic")
    instance.parameters.y_boundary_conditions = ("periodic", "periodic")
    instance.parameters.z_boundary_conditions = ("outflow", "outflow")

    # instance.stopping_conditions.number_of_steps_detection.enable()

    instance.set_has_external_gravitational_potential(1)

    instance.commit_parameters()

    grid_in_memory = instance.grid.copy()
    grid_in_memory.rho = density_gas
    pressure = 1 | units.Pa

    grid_in_memory.energy = pressure / (instance.parameters.gamma - 1)
    channel = grid_in_memory.new_channel_to(instance.grid)
    channel.copy()

    instance.initialize_grid()
    particle = Particle(
        mass=mass,
        position=length * [0.5, 0.5, 0.5],
        velocity=[0.0, 0.0, 0.0] | units.kms
    )

    gravity = Hermite(converter)
    dx = (grid_in_memory.x[1][0][0] - grid_in_memory.x[0]
          [0][0]).as_quantity_in(units.AU)
    gravity.parameters.epsilon_squared = dx**2
    gravity.particles.add_particle(particle)

    potential = gravity.get_potential_at_point(
        0 * instance.potential_grid.x.flatten(),
        instance.potential_grid.x.flatten(),
        instance.potential_grid.y.flatten(),
        instance.potential_grid.z.flatten()
    )

    potential = potential.reshape(instance.potential_grid.x.shape)
    instance.potential_grid.potential = potential

    instance.evolve_model(100 | units.yr)
    print(instance.get_timestep().value_in(units.yr))
    value_to_plot = instance.grid.rho[:, :, 0].value_in(
        units.MSun / units.AU**3)
    # value_to_plot = potential[...,...,0].value_in(potential.unit)
    plot_grid(value_to_plot)
Ejemplo n.º 18
0
def hydro_grid_in_potential_well(mass=1 | units.MSun, length=100 | units.AU):
    converter = nbody_system.nbody_to_si(mass, length)

    # calculate density in field based on solar wind
    # gives a very low number
    molar_mass_hydrogen_proton = 1 | units.g / units.mol
    density_hydrogen_in_stellar_wind = 10 | 1 / units.cm**3
    particles_per_mol = 6.022e23 | 1 / units.mol
    density_hydrogen_in_stellar_wind_in_moles = (
            density_hydrogen_in_stellar_wind
            / particles_per_mol
            )
    density_gas = 100 * (
            density_hydrogen_in_stellar_wind_in_moles
            * molar_mass_hydrogen_proton
            ).as_quantity_in(units.MSun / units.AU**3)

    # override with higher number for plotting
    density_gas = 1e-3 | units.MSun / units.AU**3

    instance = Athena(converter)
    instance.initialize_code()
    instance.parameters.nx = 50
    instance.parameters.ny = 50
    instance.parameters.nz = 1
    instance.parameters.length_x = length
    instance.parameters.length_y = length
    instance.parameters.length_z = length
    instance.parameters.x_boundary_conditions = ("periodic", "periodic")
    instance.parameters.y_boundary_conditions = ("periodic", "periodic")
    instance.parameters.z_boundary_conditions = ("outflow", "outflow")

    # instance.stopping_conditions.number_of_steps_detection.enable()

    instance.set_has_external_gravitational_potential(1)

    instance.commit_parameters()

    grid_in_memory = instance.grid.copy()
    grid_in_memory.rho = density_gas
    pressure = 1 | units.Pa

    grid_in_memory.energy = pressure / (instance.parameters.gamma - 1)
    channel = grid_in_memory.new_channel_to(instance.grid)
    channel.copy()

    instance.initialize_grid()
    particle = Particle(
        mass=mass,
        position=length * [0.5, 0.5, 0.5],
        velocity=[0.0, 0.0, 0.0] | units.kms
    )

    gravity = Hermite(converter)
    dx = (grid_in_memory.x[1][0][0] - grid_in_memory.x[0]
          [0][0]).as_quantity_in(units.AU)
    gravity.parameters.epsilon_squared = dx**2
    gravity.particles.add_particle(particle)

    potential = gravity.get_potential_at_point(
        0 * instance.potential_grid.x.flatten(),
        instance.potential_grid.x.flatten(),
        instance.potential_grid.y.flatten(),
        instance.potential_grid.z.flatten()
    )

    potential = potential.reshape(instance.potential_grid.x.shape)
    instance.potential_grid.potential = potential

    instance.evolve_model(100 | units.yr)
    print(instance.get_timestep().value_in(units.yr))
    value_to_plot = instance.grid.rho[:, :, 0].value_in(
        units.MSun / units.AU**3)
    # value_to_plot = potential[...,...,0].value_in(potential.unit)
    plot_grid(value_to_plot)
Ejemplo n.º 19
0
def new_instance_of_hydro_code(number_of_workers=1):
    result=Athena(number_of_workers = number_of_workers, mode='mhd')
    result.initialize_code()
    result.parameters.gamma = GAMMA
    result.parameters.courant_number=0.8
    return result
Ejemplo n.º 20
0
def new_instance_of_hydro_code(number_of_workers=1):
    result = Athena(number_of_workers=number_of_workers, mode='mhd')
    result.initialize_code()
    result.parameters.gamma = GAMMA
    result.parameters.courant_number = 0.8
    return result