Advertisement
shihab2196

bond_order_cutoff_analysis_single_plot_for_Molecule_A_and_B

Jan 11th, 2024
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.15 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Author: Shihab Ahmed
  4. Created on Wed Jan 10 23:26:09 2024
  5. """
  6.  
  7. import numpy as np
  8. import matplotlib.pyplot as plt
  9. import random
  10. import magnolia.speciesfile_parser as sfp
  11.  
  12.  
  13. dirrs = [r"C:\Users\arup2\OneDrive - University of California Merced\Desktop\LAMMPS\Antioxidants\ABCDE\D\D_300_O2\Production\1000K",
  14.          r"C:\Users\arup2\OneDrive - University of California Merced\Desktop\LAMMPS\Antioxidants\ABCDE\B\B_300_O2\Production\1150"]
  15.  
  16. fig, ax = plt.subplots()
  17. labels = ['Molecule A', 'Molecule B']
  18. markers = ['s','^']
  19.  
  20. for i, dirr in enumerate(dirrs):              
  21.     data = {}
  22.     all_data = {}
  23.     total_species = {}
  24.    
  25.     for cutoff in np.array(range(30,80,5))/100:
  26.         total_species[cutoff]=0
  27.        
  28.     for cutoff in np.array(range(30,80,5))/100:
  29.         sim_dir = ['\\Sim-1','\\Sim-2','\\Sim-3']
  30.         flag = True
  31.         for sim in sim_dir:
  32.             directory = dirr+sim
  33.             speciesfile = directory+f'\\species_{cutoff}.out'
  34.             if cutoff==0.30:
  35.                 speciesfile = directory+'\\species.out'
  36.             current = sfp.get_species_count(speciesfile).T
  37.             if flag:
  38.                 summed_species = current.copy()
  39.                 flag = False
  40.             else:
  41.                 summed_species = summed_species.add(current,fill_value=0)
  42.         exclude= []#['O2', 'H26C34O4']
  43.         nsim   = len(sim_dir) # number of simulation
  44.         species = (summed_species/nsim).drop(exclude,axis=1)
  45.         plt.style.use("classic")
  46.         plt.figure(figsize=(6.4, 4.8))
  47.         total_molecule = species.count(axis=1)
  48.         total_species[cutoff]+= len(species.columns)
  49.        
  50.     ax.plot(total_species.keys(),total_species.values(),marker=markers[i],
  51.             label=labels[i])
  52.    
  53.     ax.set_xlim(0.29)
  54.  
  55. ax.legend(loc='upper left')    
  56. ax.set_xlabel('Bond order cutoff')
  57. ax.set_ylabel('Total number of different species')
  58. fig.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