Ejemplo n.º 1
0
    def test3(self):
        print("Test 3: evolve")
        instance = SimpleX(**default_options)
        instance.initialize_code()
        instance.commit_parameters()

        input_file = os.path.join(os.path.dirname(__file__),
                                  "test_simplex_data.txt")
        particles = particles_from_input_file(input_file)
        particles.du_dt = particles.u / (10 | units.Myr)
        instance.particles.add_particles(particles)
        #        instance.particles.du_dt=particles.du_dt
        #        instance.commit_particles()
        instance.particles.du_dt = particles.du_dt
        self.assertAlmostEqual(instance.particles.xion.mean(), 0.0)
        self.assertAlmostEqual(
            instance.particles.du_dt.mean().in_(units.cm**2 / units.s**3),
            particles.du_dt.mean().in_(units.cm**2 / units.s**3))
        instance.evolve_model(0.5 | units.Myr)
        self.assertAlmostEqual(
            instance.particles.du_dt.mean().in_(units.cm**2 / units.s**3),
            particles.du_dt.mean().in_(units.cm**2 / units.s**3))
        self.assertAlmostEqual(instance.particles.xion.mean(),
                               0.000845247683257)
        instance.cleanup_code()
        instance.stop()
Ejemplo n.º 2
0
 def test1(self):
     print "Test 1: initialization"
     instance = SimpleX(**default_options)
     instance.initialize_code()
     instance.commit_parameters()
     instance.cleanup_code()
     instance.stop()
Ejemplo n.º 3
0
 def test1(self):
     print("Test 1: initialization")
     instance = SimpleX(**default_options)
     instance.initialize_code()
     instance.commit_parameters()
     instance.cleanup_code()
     instance.stop()
Ejemplo n.º 4
0
    def test2(self):
        print "Test 2: commit_particles, getters and setters"
        instance = SimpleX(**default_options)
        instance.initialize_code()
        instance.commit_parameters()
        
        input_file = os.path.join(os.path.dirname(__file__), "test_simplex_data.txt")
        particles = particles_from_input_file(input_file)
        instance.particles.add_particles(particles)
        instance.commit_particles()
#        for attribute in ['position', 'rho', 'flux', 'xion']:
#            self.assertAlmostEqual(13200.*getattr(particles, attribute),
#                                   13200.*getattr(instance.particles, attribute), 5)
#            setattr(instance.particles, attribute, getattr(particles, attribute)/2.0)
#            self.assertAlmostEqual(13200.*getattr(particles, attribute)/2.0,
#                                   13200.*getattr(instance.particles, attribute), 5)
        instance.cleanup_code()
        instance.stop()
Ejemplo n.º 5
0
    def test2(self):
        print "Test 2: commit_particles, getters and setters"
        instance = SimpleX(**default_options)
        instance.initialize_code()
        instance.commit_parameters()
        
        input_file = os.path.join(os.path.dirname(__file__), "test_simplex_data.txt")
        particles = particles_from_input_file(input_file)
        instance.particles.add_particles(particles)
        instance.commit_particles()
#        for attribute in ['position', 'rho', 'flux', 'xion']:
#            self.assertAlmostEqual(13200.*getattr(particles, attribute),
#                                   13200.*getattr(instance.particles, attribute), 5)
#            setattr(instance.particles, attribute, getattr(particles, attribute)/2.0)
#            self.assertAlmostEqual(13200.*getattr(particles, attribute)/2.0,
#                                   13200.*getattr(instance.particles, attribute), 5)
        instance.cleanup_code()
        instance.stop()
Ejemplo n.º 6
0
def iliev_test_5( N=10000,
                  Ns=10,
                  L=15. | units.kpc,
                  dt=None):
  """
  prepare iliev test and return SPH and simplex interfaces
  """  
  gas,sources=iliev_test_5_ic(N,Ns,L)                


  conv=nbody_system.nbody_to_si(1.0e9 | units.MSun, 1.0 | units.kpc)
     
  sph=Fi(conv,use_gl=False,mode='periodic',redirection='none')   
  sph.initialize_code()

  sph.parameters.use_hydro_flag=True
  sph.parameters.radiation_flag=False
  sph.parameters.self_gravity_flag=False
  sph.parameters.gamma=1
  sph.parameters.isothermal_flag=True
  sph.parameters.integrate_entropy_flag=False
  sph.parameters.timestep=dt  
  sph.parameters.verbosity=0
  sph.parameters.pboxsize=2*L
  sph.commit_parameters()
  sph.gas_particles.add_particles(gas)
  sph.commit_particles()

#  sph.start_viewer()
         
  rad=SimpleX(number_of_workers = 1,redirection='none')
  rad.initialize_code()

  rad.parameters.box_size=2*L
  rad.parameters.hilbert_order=0

  rad.commit_parameters()

  gas.add_particles(sources)
  rad.particles.add_particles(gas)
  rad.commit_particles()
                  
  return sph,rad                  
Ejemplo n.º 7
0
    def test3(self):
        print "Test 3: evolve"
        instance = SimpleX(**default_options)
        instance.initialize_code()
        instance.commit_parameters()
        
        input_file = os.path.join(os.path.dirname(__file__), "test_simplex_data.txt")
        particles = particles_from_input_file(input_file)
        particles.du_dt = particles.u/(10|units.Myr)
        instance.particles.add_particles(particles)
#        instance.particles.du_dt=particles.du_dt
#        instance.commit_particles()
        instance.particles.du_dt=particles.du_dt
        self.assertAlmostEqual(instance.particles.xion.mean(), 0.0)
        self.assertAlmostEqual(instance.particles.du_dt.mean().in_(units.cm**2/units.s**3),particles.du_dt.mean().in_(units.cm**2/units.s**3))
        instance.evolve_model(0.5 | units.Myr)
        self.assertAlmostEqual(instance.particles.du_dt.mean().in_(units.cm**2/units.s**3),particles.du_dt.mean().in_(units.cm**2/units.s**3))
        self.assertAlmostEqual(instance.particles.xion.mean(), 0.000845247683257)
        instance.cleanup_code()
        instance.stop()
Ejemplo n.º 8
0
def iliev_test_5(N=10000, Ns=10, L=15. | units.kpc, dt=None):
    """
    prepare iliev test and return SPH and simplex interfaces
    """
    gas, sources = iliev_test_5_ic(N, Ns, L)

    conv = nbody_system.nbody_to_si(1.0e9 | units.MSun, 1.0 | units.kpc)

    sph = Fi(conv, use_gl=False, mode='periodic', redirection='none')
    sph.initialize_code()

    sph.parameters.use_hydro_flag = True
    sph.parameters.radiation_flag = False
    sph.parameters.self_gravity_flag = False
    sph.parameters.gamma = 1
    sph.parameters.isothermal_flag = True
    sph.parameters.integrate_entropy_flag = False
    sph.parameters.timestep = dt
    sph.parameters.verbosity = 0
    sph.parameters.pboxsize = 2 * L
    sph.commit_parameters()
    sph.gas_particles.add_particles(gas)
    sph.commit_particles()

    #  sph.start_viewer()

    rad = SimpleX(number_of_workers=1, redirection='none')
    rad.initialize_code()

    rad.parameters.box_size = 2 * L
    rad.parameters.hilbert_order = 0

    rad.commit_parameters()

    gas.add_particles(sources)
    rad.particles.add_particles(gas)
    rad.commit_particles()

    return sph, rad