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
 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
Example #3
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
Example #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, 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
 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
Example #6
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
Example #7
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)
 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