Advertisement
shihab2196

species_vs_cutoffs

Dec 12th, 2023
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.44 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Author: Shihab Ahmed
  4. Created on Tue Dec 12 01:22:20 2023
  5. """
  6. import pandas as pd
  7. import matplotlib.pyplot as plt
  8. import random
  9. import magnolia.speciesfile_parser as sfp
  10. import numpy as np
  11.                
  12.                
  13.  
  14. base_oil = 'PAO4'
  15. spec = 'H2O'
  16.  
  17. plt.style.use("classic")
  18. plt.figure(figsize=(6.4, 4.8))
  19. for cutoff in np.array(range(30,76,5))/100:    
  20.     commmon = r"C:\Users\arup2\OneDrive - University of California Merced\Desktop\LAMMPS\Base_Oil\{}\25_{}_200_O2_Soria\Production\1600".format(base_oil,base_oil)
  21.    
  22.     sim_dir = ['\\Sim-1','\\Sim-2','\\Sim-3']
  23.     flag = True
  24.     for sim in sim_dir:
  25.         directory = commmon+sim
  26.         speciesfile = directory+f'\\species_{cutoff}.out'
  27.         if cutoff==0.30:
  28.             speciesfile = directory+'\\species.out'
  29.         current = sfp.get_species_count(speciesfile).T
  30.         if flag:
  31.             summed_species = current.copy()
  32.             upper_bound_   = current.copy()
  33.             lower_bound_   = current.copy()
  34.             flag = False
  35.         else:
  36.             summed_species = summed_species.add(current,fill_value=0)
  37.             ## geting upper bound
  38.             maxx = lambda s1, s2: s1.where(s1 > s2, s2)
  39.             upper_bound_ = upper_bound_.combine(current, maxx)
  40.             ## getting lower bound
  41.             minn = lambda s1, s2: s1.where(s1 < s2, s2)
  42.             lower_bound_ = lower_bound_.combine(current, minn)
  43.    
  44.    
  45.    
  46.    
  47.    
  48.     number_of_main = 25  
  49.     species_cutoff = 4
  50.     skipts = (1600-300)/4
  51.     exclude= ['O2', 'H62C30']
  52.     nsim   = len(sim_dir) # number of simulation
  53.    
  54.     species     = summed_species/nsim
  55.     upper_bound = upper_bound_.copy()
  56.     lower_bound = lower_bound_.copy()
  57.    
  58.     last_count = species.iloc[-1,:].sort_values(ascending=False)
  59.     species    = species.loc[:,last_count.index]
  60.     species = species.loc[:,(species>=species_cutoff).any()]
  61.     species = species.drop(exclude,axis=1)
  62.     species.index = species.index*0.25/1000
  63.     species = species.loc[skipts:,:]
  64.     species.index = species.index-skipts
  65.     species = species.loc[:,spec]
  66.    
  67.     ## adjusting the index of upper_bound
  68.     upper_bound.index = upper_bound_.index*0.25/1000
  69.     upper_bound = upper_bound.loc[skipts:,:]
  70.     upper_bound.index = upper_bound.index-skipts
  71.     ## adjusting the index of lower_bound
  72.     lower_bound.index = lower_bound_.index*0.25/1000
  73.     lower_bound = lower_bound.loc[skipts:,:]
  74.     lower_bound.index = lower_bound.index-skipts
  75.    
  76.     # lower_bound = lower_bound[:,spec]
  77.     # upper_bound = upper_bound[:,spec]
  78.    
  79.    
  80.     time = species.index
  81.    
  82.     colors = iter(['b', 'g', 'r', 'c', 'm', 'y', 'k'])    
  83.     # color = next(colors)
  84.     plt.plot(time,species.values,linewidth=0.8, label=cutoff)
  85.     # plt.fill_between(time, lower_bound[species.name], upper_bound[species.name],
  86.     #                  alpha=0.1)
  87.    
  88. plt.legend(fontsize=10,loc='upper left')
  89. # plt.ylim(-0.1,)
  90. plt.xlabel('Time (ps)',fontsize=15)
  91. plt.ylabel('Number of molecules',fontsize=15)
  92. title = f'This plot is generated from species file (cutoff: {cutoff}), spec={spec}'
  93. plt.title(directory[directory.find('Base'):]+'\n'+title+'\n',fontsize=8)
  94. plt.grid('on')
  95. plt.savefig(r'C:\Users\arup2\OneDrive - University of California Merced\Desktop\LAMMPS\Post Processing\lammps_processing\python_outputs\species'+'\\species_speciesfile{}'.format(random.randint(0,10000000000)),dpi=400,bbox_inches='tight')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement