Coverage for gamdpy/simulation/get_default_sim.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2025-06-14 15:55 +0200

1"Return a sim object of the single component LJ crystal in the NVT ensemble." 

2 

3def get_default_sim(): 

4 """ Return a sim object of the single component LJ crystal in the NVT ensemble. 

5 The purpose of this function is to provide a default simulation for testing and simplifying examples. 

6 

7 Example 

8 ------- 

9 

10 >>> import os 

11 >>> os.environ['NUMBA_CUDA_LOW_OCCUPANCY_WARNINGS'] = '0' # Removes warnings from low occupacy (optional) 

12 >>> import gamdpy as gp 

13 >>> sim = gp.get_default_sim() 

14 

15 """ 

16 import gamdpy as gp 

17 

18 # Setup configuration: FCC Lattice 

19 configuration = gp.Configuration(D=3) 

20 configuration.make_lattice(gp.unit_cells.FCC, cells=[8, 8, 8], rho=0.973) 

21 configuration['m'] = 1.0 

22 temperature = 0.7 

23 configuration.randomize_velocities(temperature=temperature) 

24 

25 # Setup pair potential: Single component 12-6 Lennard-Jones 

26 pair_func = gp.apply_shifted_potential_cutoff(gp.LJ_12_6_sigma_epsilon) 

27 sig, eps, cut = 1.0, 1.0, 2.5 

28 pair_pot = gp.PairPotential(pair_func, params=[sig, eps, cut], max_num_nbs=1000) 

29 

30 # Setup integrator: NVT 

31 integrator = gp.integrators.NVT(temperature=temperature, tau=0.2, dt=0.005) 

32 

33 # Setup runtime actions, i.e. actions performed during simulation of timeblocks 

34 runtime_actions = [gp.TrajectorySaver(), 

35 gp.ScalarSaver(), 

36 gp.MomentumReset(100)] 

37 

38 

39 # Setup Simulation 

40 sim = gp.Simulation(configuration, pair_pot, integrator, runtime_actions, 

41 num_timeblocks=8, steps_per_timeblock=1024, 

42 storage='memory') 

43 return sim