Coverage for examples/plot_isomorph_dynamics.py: 100%

26 statements  

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

1""" Plot data generated py isomorph.py 

2 

3""" 

4 

5import pickle 

6import os 

7 

8import matplotlib.pyplot as plt 

9 

10# Load data from pickle file 

11with open('Data/isomorph.pkl','rb') as f: 

12 data = pickle.load(f) 

13 

14# Setup figure  

15fig, axs = plt.subplots(3, 1, figsize=(8,9), sharex=True) 

16fig.subplots_adjust(hspace=0.00) # Remove vertical space between axes 

17axs[0].set_ylabel('Reduced MSD') 

18axs[1].set_ylabel('Non Gaussian parameter') 

19axs[2].set_ylabel('Intermediate scattering function') 

20axs[2].set_xlabel('Reduced Time') 

21axs[0].grid(linestyle='--', alpha=0.5) 

22axs[1].grid(linestyle='--', alpha=0.5) 

23axs[2].grid(linestyle='--', alpha=0.5) 

24 

25# Loop over simulation (i.e. elements in the list of data) 

26for simulation in data: 

27 

28 # Unpack data for convenience 

29 rho = simulation['rho'] 

30 T = simulation['T'] 

31 dynamics = simulation['dynamics'] 

32 

33 # Do the actual plotting in reduced units 

34 axs[0].loglog(dynamics['times']*rho**(1/3)*float(T)**0.5, dynamics['msd']*rho**(2/3), 

35 'o--', label=f'rho={rho:.3f}, T={T:.3f}') 

36 axs[1].semilogx(dynamics['times']*rho**(1/3)*float(T)**0.5, dynamics['alpha2'], 

37 'o--', label=f'rho={rho:.3f}, T={T:.3f}') 

38 axs[2].semilogx(dynamics['times']*rho**(1/3)*float(T)**0.5, dynamics['Fs'], 

39 'o--', label=f'rho={rho:.3f}, T={T:.3f}, q={dynamics["qvalues"][0]:.3f}') 

40 

41# Final touches and saving  

42axs[0].loglog(dynamics['times'][:8], 3*dynamics['times'][:8]**2, 

43 'k-', label=f'Ballistic prediction', alpha=0.5) 

44axs[0].legend(loc='upper left') 

45axs[2].legend() 

46 

47fig.tight_layout() 

48#fig.subplots_adjust(hspace=0.00) # Remove vertical space between axes 

49fig.savefig('isomorph_dynamics.pdf') 

50#plt.show() 

51