def main(): #my_test() np.seterr(all='ignore') options = arg.parse_args() cfg = pc.ParticlesConfig() if options.version : print( py_particle_version() ) return if options.about : about() return if options.test : print("") print("Start a test simulation:") print(" It compares the simulated solution with the analytical solution in a specific problem") tst.test( options.test ) return if options.config_model : file_name = "example_pyparticles_config.cfg" cfg.write_example_config_file("example_pyparticles_config.cfg") print( "A file named: %s has been written in the current directory" % file_name ) print( "" ) return if options.demo == "fountain" : print("") print("Start the simulation example:") print(" 250K Particles fountain") fou.fountain() return if options.demo == "springs" : print("") print("Start the simulation example:") print(" 3 body springs") spr.springs() return if options.demo == "cat_spri" : print("") print("Start the simulation example:") print(" catenary springs (constraints demo)") spc.spring_constr() return if options.demo == "gas_lj" : print("") print("Start the simulation example:") print(" Pseudo gas with Lennard Jones potential") lj.gas_lj() return if options.demo == "bubble" : print("") print("Start the simulation example:") print(" Pseudo bubble demo") bu.bubble() return if options.demo == "el_static" : print("") print("Start the simulation example:") print(" electrostatic") eld.electro() return if options.demo == "elmag_field" : print("") print("Start the simulation example:") print(" electromagnetic fields") emd.electromag_field() return if options.demo == "galaxy" : print("") print("Start the simulation example:") print(" Gravitational clusters") grav.gravity_cluster() return if options.demo == "smoothed_particle_hydrodynamics" : print("") print("Start the simulation example:") print(" smoothed particle hydrodynamics") sph.cube_water() return if options.path_name == None or options.demo == "solar_system": print("") print("Start the simulation example:") print(" Solar system") print(" -- Try to watch the Moon ... around the Earth ") print("") print(" Use your mouse for rotating, zooming and tranlating the scene.") print("") print("For more details type:") print(" pyparticles --help") print("") sol.solar_system() return if options.path_name != None : cfg.read_config( options.path_name ) ( an , pset , force , ode_solver ) = cfg.build_problem() an.build_animation() print("") print("Start the simulation described in: %s ... " % options.path_name ) an.start() return print("Ops ... ") return
def main(): #my_test() np.seterr(all='ignore') options = arg.parse_args() cfg = pc.ParticlesConfig() if options.version : print( py_particle_version() ) return if options.config_model : file_name = "example_pyparticles_config.cfg" cfg.write_example_config_file("example_pyparticles_config.cfg") print( "A file named: %s has been written in the current directory" % file_name ) print( "" ) return if options.demo == "springs" : print("") print("Start the simulation example:") print(" 3 body springs") spr.springs() return if options.demo == "gas_lj" : print("") print("Start the simulation example:") print(" Pseudo gas with Lennard Jones potential") lj.gas_lj() return if options.demo == "bubble" : print("") print("Start the simulation example:") print(" Pseudo bubble demo") bu.bubble() return if options.path_name == None or options.demo == "solar_system": print("") print("Start the simulation example:") print(" Solar system") print(" -- Try to watch the Moon ... around the Earth ") print("") print(" Use your mouse for rotating, zooming and tranlating the scene.") print("") print("For more details type:") print(" pyparticles --help") print("") sol.solar_system() return if options.path_name != None : cfg.read_config( options.path_name ) ( an , pset , force , ode_solver ) = cfg.build_problem() an.build_animation() print("") print("Start the simulation described in: %s ... " % options.path_name ) an.start() return print("Ops ... ") return
def main(): #my_test() np.seterr(all='ignore') options = arg.parse_args() cfg = pc.ParticlesConfig() if options.version : print( py_particle_version() ) return if options.about : about() return if options.test : print("") print("Start a test simulation:") print(" It compares the simulated solution with the analytical solution in a specific problem") tst.test( options.test ) return if options.config_model : file_name = "example_pyparticles_config.cfg" cfg.write_example_config_file("example_pyparticles_config.cfg") print( "A file named: %s has been written in the current directory" % file_name ) print( "" ) return if options.demo == "fountain" : print("") print("Start the simulation example:") print(" 250K Particles fountain") fou.fountain() return if options.demo == "springs" : print("") print("Start the simulation example:") print(" 3 body springs") spr.springs() return if options.demo == "cat_spri" : print("") print("Start the simulation example:") print(" catenary springs (constraints demo)") spc.spring_constr() return if options.demo == "gas_lj" : print("") print("Start the simulation example:") print(" Pseudo gas with Lennard Jones potential") lj.gas_lj() return if options.demo == "bubble" : print("") print("Start the simulation example:") print(" Pseudo bubble demo") bu.bubble() return if options.demo == "el_static" : print("") print("Start the simulation example:") print(" electrostatic") eld.electro() return if options.demo == "elmag_field" : print("") print("Start the simulation example:") print(" electromagnetic fields") emd.electromag_field() return if options.demo == "galaxy" : print("") print("Start the simulation example:") print(" Gravitational clusters") grav.gravity_cluster() return if options.path_name == None or options.demo == "solar_system": print("") print("Start the simulation example:") print(" Solar system") print(" -- Try to watch the Moon ... around the Earth ") print("") print(" Use your mouse for rotating, zooming and tranlating the scene.") print("") print("For more details type:") print(" pyparticles --help") print("") sol.solar_system() return if options.path_name != None : cfg.read_config( options.path_name ) ( an , pset , force , ode_solver ) = cfg.build_problem() an.build_animation() print("") print("Start the simulation described in: %s ... " % options.path_name ) an.start() return print("Ops ... ") return
def my_test() : bu.bubble() n = 10 dt = 0.005 #dt = 0.0023453 steps = 1000000 G = 0.001 #G = 6.67384e-11 FLOOR = -10 CEILING = 10 #ff = fc.FileCluster() #ff.open( options.path_name ) pset = ps.ParticlesSet( n , label=True ) pset.label[8] = "tttt" pset.label[9] = "tzzzttt" pset.add_property_by_name("ciao",dim=1 , model="list") pset.get_by_name("ciao")[3] = 100 pset.get_by_name("X")[3,:] = 101 sz = 2000 pset.resize( sz ) tree = ot.OcTree() pset.get_by_name("X")[:] = np.random.rand(sz,3) pset.get_by_name("M")[:] = 1.0 pset.update_centre_of_mass() print(" C O M pset") print( pset.centre_of_mass() ) print("") tree.set_global_boundary() a = time.time() tree.build_tree( pset ) b = time.time() print( "Tot time: % f" %(b-a) ) C = np.array([0.5,0.4,0.3]) R = 0.05 a = time.time() for ix in range( pset.size ): nl = tree.search_neighbour( pset.X[ix,:] , R ) b = time.time() print( "Tot time octree : % f" %(b-a) ) nl = np.sort( nl ) print("") print("nl:") print( nl ) print("") print("dd:") a = time.time() for ix in range( pset.size ): dd = np.sqrt( np.sum( (pset.X[ix,:] - pset.X)**2 , 1 ) ) din, = np.where( dd <= R ) b = time.time() print( "Tot time numpy : % f" %(b-a) ) print( din ) print(" C O M") print( tree.centre_of_mass ) print("") print ( np.all( nl == din ) ) #tree.print_tree() #print( pset.get_by_name( "ciao" ) ) #print( pset.get_by_name( "X" ) ) #print("") #print( pset.X ) #print( pset.label ) exit() return #ff.insert3( pset ) #ff.close() #pset.unit = 149597870700.0 #pset.mass_unit = 5.9736e24 cs = clu.RandCluster() cs.insert3( pset.X , M=pset.M , V=pset.V , n = n/2 , centre=(-1.5,1,0.5) , mass_rng=(0.5,5.0) , vel_rng=(0,0) , vel_mdl="bomb" ) cs.insert3( pset.X , M=pset.M , V=pset.V , start_indx=int(n/2) , n = int(n/2) , centre=(1.5,-0.5,0.5) , vel_rng=(0.2,0.4) , vel_mdl="const" , vel_dir=[-1.0,0.0,0.0] ) # grav = gr.Gravity( pset.size , Consts=G ) #grav = cf.ConstForce(n , u_force=[0,0,-1.0] ) #grav = MyField( pset.size , dim=3 ) #grav = ls.LinearSpring( pset.size , Consts=10e8 ) grav.set_masses( pset.M ) bound = None #bound = pb.PeriodicBoundary( (-50.0 , 50.0) ) #bound = rb.ReboundBoundary( (-10.0 , 10.0) ) pset.set_boundary( bound ) grav.update_force( pset ) solver = els.EulerSolver( grav , pset , dt ) #solver = lps.LeapfrogSolver( grav , pset , dt ) #solver = svs.StormerVerletSolver( grav , pset , dt ) #solver = rks.RungeKuttaSolver( grav , pset , dt ) a = aogl.AnimatedGl() # a = anim.AnimatedScatter() a.xlim = ( FLOOR , CEILING ) a.ylim = ( FLOOR , CEILING ) a.zlim = ( FLOOR , CEILING ) a.ode_solver = solver a.pset = pset a.steps = steps a.build_animation() a.start() return