Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Author: Shihab Ahmed
- Created on Fri Dec 8 13:29:43 2023
- """
- import numpy as np
- import pandas as pd
- import matplotlib.pyplot as plt
- import random
- def get_species_count(speciesfile):
- with open(speciesfile,'r') as sf:
- species = {}
- for line in sf:
- if "Timestep" in line:
- headers = line.strip().split()[1:] # not taking '#'
- species_name = headers[3:] # skip Timestep, No_moles, No_Specs
- else:
- values = [int(x) for x in line.strip().split()]
- timestep = values[0]
- species_count = values[3:]
- species[timestep]={}
- for key,value in zip(species_name,species_count):
- if key in species:
- species[timestep][key]+=value
- else:
- species[timestep][key] = value
- df = pd.DataFrame(species).fillna(0)
- df.index.name = 'Timestep'
- return df
- base_oil = 'PAO4'
- data = {}
- for cutoff in np.array(range(30,76,5))/100:
- 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)
- sim_dir = ['\\Sim-1','\\Sim-2','\\Sim-3']
- flag = True
- for sim in sim_dir:
- directory = commmon+sim
- speciesfile = directory+f'\\species_{cutoff}.out'
- if cutoff==0.30:
- speciesfile = directory+'\\species.out'
- current = get_species_count(speciesfile).T
- if flag:
- summed_species = current.copy()
- flag = False
- else:
- summed_species = summed_species.add(current,fill_value=0)
- exclude= ['O2', 'H62C30']
- nsim = len(sim_dir) # number of simulation
- species = (summed_species/nsim).drop(exclude,axis=1)
- plt.style.use("classic")
- plt.figure(figsize=(6.4, 4.8))
- total_molecule = species.sum(axis=1)
- last_value = total_molecule.iloc[-1:].mean()
- data[cutoff]=last_value
- plt.plot(data.keys(),data.values(),marker='s',c='r')
- plt.xlim(0.29)
- plt.xlabel('Bond order cutoff')
- plt.ylabel('Total number of reaction products')
- 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