示例#1
0
文件: common.py 项目: AstroGPU/swarm
        def runTest(self):
            swarmng.init(self.cfg)
            integ = swarmng.Integrator.create( self.cfg )
            self.ref = self.createEnsemble()
            self.ens = self.ref.clone()

            integ.ensemble = self.ens
            integ.destination_time = self.destination_time
            integ.integrate()
            self.ens.save_to_text("integrator_test_hermite.txt")
            self.examine()
示例#2
0
文件: common.py 项目: kb3vwt/swarm
        def runTest(self):
            swarmng.init(self.cfg)
            integ = swarmng.Integrator.create(self.cfg)
            self.ref = self.createEnsemble()
            self.ens = self.ref.clone()

            integ.ensemble = self.ens
            integ.destination_time = self.destination_time
            integ.integrate()
            self.ens.save_to_text("integrator_test_hermite.txt")
            self.examine()
示例#3
0
        def do_integration():
            cfg = swarmng.config(nsys=64,
                                 nbod=3,
                                 log_writer='bdb',
                                 log_output_db=output_file_name,
                                 log_interval=1,
                                 integrator='hermite_cpu_log',
                                 time_step=0.01,
                                 nogpu=1)
            ref = swarmng.generate_ensemble(cfg)
            ens = ref.clone()

            swarmng.init(cfg)

            integ = swarmng.Integrator.create(cfg)

            integ.ensemble = ens

            swarmng.sync
            for i in range(1, final_time + 1):
                integ.destination_time = i
                integ.integrate()
示例#4
0
    def do_integration():
      cfg = swarmng.config(
	nsys=64,
	nbod=3,
	log_writer='bdb',
	log_output_db=output_file_name,
	log_interval=1,
	integrator='hermite_cpu_log',
	time_step=0.01,
	nogpu=1
      );
      ref = swarmng.generate_ensemble( cfg )
      ens = ref.clone()

      swarmng.init(cfg)

      integ = swarmng.Integrator.create( cfg )

      integ.ensemble = ens
    
      swarmng.sync
      for i in range(1,final_time+1):
	integ.destination_time = i
	integ.integrate()
示例#5
0
#
# Source code for this tutorial can be found at @ref py/tutorial.py
#
# First thing is to import swarmng package. It is located in `\<SOURCE DIRECTORY\>/py/swarmng/`
# It takes care of loading the libswarmng_ext.so; it also contains some Pythonified
# API on top of libswarmng_ext. But please run the scripts
# from your build directory so swarmng can find your libraries.
import swarmng
import os

# swarm functions cannot take hashes for config. So
# we have to create the special config object (a C++ std::map)
# using swarmng.config function
# This first line initializes Swarm-NG. 'nogpu' option
# allows us to run this script on a machine without GPU
swarmng.init(swarmng.config(nogpu=1))

# Now we can load an ensemble from a text file. The ensemble file is in the swarm source directory:
ensemble_filename = os.path.join(swarmng.SWARMDIR,
                                 'test/integrators/test.3.in.txt')
# We use a simple call that loads the file and returns the data structure
ref = swarmng.DefaultEnsemble.load_from_text(ensemble_filename)

# We can also look into the data structure and view the values
for s in ref:
    print("System {0}, time: {1}, state: {2} ".format(s.id, s.time, s.state))
    for i, b in enumerate(s):
        print("\tBody {0} pos: {1}\tvel:{2}".format(i, b.pos, b.vel))

# We can treat the data structure as an array. e.g to set the position
# of body 0 of system 3 you can write:
示例#6
0
#!/usr/bin/env python2
# -*- coding: utf8 -*-

import swarmng
import time

for c in range(0,2):
    swarmng.init(swarmng.config(CUDA_DEVICE=c,verbose=1))

    integ = swarmng.Integrator.create(swarmng.config(integrator="hermite",time_step=0.001))

    times = []

    for nb in range(3,7):
        integ.ensemble = swarmng.generate_ensemble(swarmng.config(nsys=8000,nbod=nb))
        integ.destination_time = 10.0

        start = time.clock()
        integ.integrate()
        times.append(time.clock() - start)

    print(times)




示例#7
0
        nogpu      = 1,
        deactivate_on_ejection = 1,
        rmax       = RMAX
        )
# We have to set the destination_time directly on the integrator object
# and it cannot be included in the Config object.
destination_time = 100
#
# We create an ensemble with very close orbits. This ensures that the planets
# will come close at some point and the result would be an ejection.
ens = make_test_case(nsys=20, nbod = 6, spacing_factor=1.01);
#
# \section int Integration
# Same procedure as in @ref TutorialPython. Set-up the integrator parameters and
# call the method @ref swarmng.Integrator.integrate "integrate".
swarmng.init(cfg)
integ = swarmng.Integrator.create( cfg )
integ.ensemble = ens
integ.destination_time = destination_time
integ.integrate()
#
# \section ex Examine
# After the integration finished, we can look into the ensemble to see if
# in fact the integrator has worked as expected.
#
# 
for s in ens:
  for b in s:
    if( b.distance_to_origin() > RMAX ):
      assert(s.state == -1)
#
示例#8
0
                     time_step=1e-3,
                     nogpu=1,
                     deactivate_on_ejection=1,
                     rmax=RMAX)
# We have to set the destination_time directly on the integrator object
# and it cannot be included in the Config object.
destination_time = 100
#
# We create an ensemble with very close orbits. This ensures that the planets
# will come close at some point and the result would be an ejection.
ens = make_test_case(nsys=20, nbod=6, spacing_factor=1.01)
#
# \section int Integration
# Same procedure as in @ref TutorialPython. Set-up the integrator parameters and
# call the method @ref swarmng.Integrator.integrate "integrate".
swarmng.init(cfg)
integ = swarmng.Integrator.create(cfg)
integ.ensemble = ens
integ.destination_time = destination_time
integ.integrate()
#
# \section ex Examine
# After the integration finished, we can look into the ensemble to see if
# in fact the integrator has worked as expected.
#
#
for s in ens:
    for b in s:
        if (b.distance_to_origin() > RMAX):
            assert (s.state == -1)
#
示例#9
0
#
# Source code for this tutorial can be found at @ref py/tutorial.py
#
# First thing is to import swarmng package. It is located in `\<SOURCE DIRECTORY\>/py/swarmng/`
# It takes care of loading the libswarmng_ext.so; it also contains some Pythonified
# API on top of libswarmng_ext. But please run the scripts
# from your build directory so swarmng can find your libraries.
import swarmng
import os

# swarm functions cannot take hashes for config. So 
# we have to create the special config object (a C++ std::map)
# using swarmng.config function
# This first line initializes Swarm-NG. 'nogpu' option
# allows us to run this script on a machine without GPU
swarmng.init(swarmng.config(nogpu=1))

# Now we can load an ensemble from a text file. The ensemble file is in the swarm source directory:
ensemble_filename = os.path.join(swarmng.SWARMDIR , 'test/integrators/test.3.in.txt')
# We use a simple call that loads the file and returns the data structure
ref = swarmng.DefaultEnsemble.load_from_text( ensemble_filename )


# We can also look into the data structure and view the values
for s in ref:
  print("System {0}, time: {1}, state: {2} ".format(s.id, s.time, s.state))
  for i,b in enumerate(s):
    print("\tBody {0} pos: {1}\tvel:{2}".format(i,b.pos,b.vel))

# We can treat the data structure as an array. e.g to set the position
# of body 0 of system 3 you can write: