<jupyter_start><jupyter_text>Single simulation analysis Here we create a fafile object that pulls the data from the sim.hdf5 file and outputs the arrays for plotting.<jupyter_code>print "Currently in directory:", os.getcwd()
# THIS IS THE ONLY PART OF THE CODE THAT NEEDS TO BE CHANGED
dir_name = "/Users/Dmitry/Documents/Research/MSU/4tce/cis/"
h5filename = "sim.1.hdf5"
os.chdir(dir_name)
an = pyspawn.fafile(h5filename)

an.fill_electronic_state_populations(column_filename="N.dat")
an.fill_labels()
an.fill_istates()
an.get_numstates()

times = an.datasets["quantum_times"]
el_pop = an.datasets["electronic_state_populations"]
istates = an.datasets["istates"]
labels = an.datasets["labels"]
ntraj = len(an.datasets["labels"])
nstates = an.datasets['numstates']
an.fill_nuclear_bf_populations()

# write files with energy data for each trajectory
an.fill_trajectory_energies(column_file_prefix="E")

# write file with time derivative couplings for each trajectory
an.fill_trajectory_tdcs(column_file_prefix="tdc")

# compute Mulliken population of each trajectory
an.fill_mulliken_populations(column_filename="mull.dat")

mull_pop = an.datasets["electronic_state_populations"]

# istates dict
an.create_istate_dict()
istates_dict = an.datasets['istates_dict']<jupyter_output>{'00b2': 0, '00b3': 0, '00': 1, '00b1': 0, '00b0': 0}<jupyter_text>This part takes care of xyz trajectory files, bonds, angles (need to have atoms array for this to work)<jupyter_code># writing xyz files
an.write_xyzs()

# list of bonds to keep track of
bonds_list = np.array([[3, 11]])
# write datasets for bonds
an.fill_trajectory_bonds(bonds_list, column_file_prefix="bonds")

# dihedral angles list
diheds_list = np.array([[2, 6, 9, 10]])
# write datasets for dihedral angles
an.fill_trajectory_diheds(diheds_list, column_file_prefix="diheds")<jupyter_output><empty_output><jupyter_text>Loading the arrays for plotting<jupyter_code>arrays = ("poten", "pop", "toten", "aven", "kinen", "time", "tdc", "bonds", "diheds")
# creating dictionary for the datasets we want to plot
# keys are trajectory labels
for array in arrays:
    exec(array + "= dict()")

for traj in an.datasets["labels"]:
    
    poten[traj] = an.datasets[traj + "_poten"]
    toten[traj] = an.datasets[traj + "_toten"]
    kinen[traj] = an.datasets[traj + "_kinen"]
    time[traj] = an.datasets[traj + "_time"]
    tdc[traj] = an.datasets[traj + "_tdc"]
    bonds[traj] = an.datasets[traj + "_bonds"]
    diheds[traj] = an.datasets[traj + "_diheds"]<jupyter_output><empty_output><jupyter_text>Setting plotting parameters(Perhaps there is a better way to do it, right now these hardcoded color and styles limit us to 7 electronic states and 16 trajectories. However, one could argue that more lines on a single plot would not be very informative anyway)<jupyter_code>colors = ("r", "g", "b", "m", "y", "k", "k")
linestyles = ("-", "--", "-.", ":","-","-","-","-","-","-","-","-","-","-","-","-")
markers=("None","None","None","None","d","o","v","^","s","p","d","o","v","^","s","p")
large_size = 20
medium_size = 18
small_size = 16<jupyter_output><empty_output><jupyter_text>This widget picks the trajectories we want to plot in case there are many of them<jupyter_code>labels_to_plot_widget = widgets.SelectMultiple(
    options=labels,
    value=['00'],
    rows=10,
    description='Trajectories',
    disabled=False
)
display(labels_to_plot_widget)<jupyter_output><empty_output><jupyter_text>Plotting Total Energies<jupyter_code>%matplotlib notebook
traj_plot.plot_total_energies(time, toten, labels_to_plot_widget.value, istates_dict, colors, markers, linestyles)<jupyter_output><empty_output><jupyter_text>Total Population<jupyter_code>populated_states = np.amax(istates) + 1
traj_plot.plot_total_pop(times, mull_pop, populated_states, colors)<jupyter_output><empty_output><jupyter_text>Plotting Potential Energies<jupyter_code>display(labels_to_plot_widget)
%matplotlib notebook
traj_plot.plot_energies(labels_to_plot_widget.value, time, poten, nstates, colors, linestyles)<jupyter_output><empty_output><jupyter_text>Plotting Energy gaps<jupyter_code>display(labels_to_plot_widget)
%matplotlib notebook
# Gap between ground and first excited states
state1 = 0
state2 = 1
traj_plot.plot_e_gap(time, poten, labels_to_plot_widget.value, state1, state2, istates_dict,
                     colors, linestyles, markers)
%matplotlib notebook
spawnthresh = 0.00785
# plot_tdc(labels, time, tdc, nstates, spawnthresh)
traj_plot.plot_tdc(time, tdc, labels_to_plot_widget.value,
                   nstates, istates_dict, spawnthresh, colors, linestyles, markers)<jupyter_output><empty_output><jupyter_text>Bonds<jupyter_code>display(labels_to_plot_widget)
%matplotlib notebook
traj_plot.plot_bonds(time, labels_to_plot_widget.value, bonds_list, bonds, colors, linestyles)<jupyter_output><empty_output><jupyter_text>Dihedral Angles<jupyter_code>%matplotlib notebook
traj_plot.plot_diheds(time, labels_to_plot_widget.value, diheds_list, diheds, colors, linestyles)
plt.savefig('/Users/Dmitry/Documents/Research/MSU/4tce/cis/angles.png', dpi=300)<jupyter_output><empty_output><jupyter_text>Trajectory visualization In this widget we pick the trajectory label to visualize<jupyter_code>xyz_widget = widgets.RadioButtons(
    options=labels,
#     value='pineapple',
    description='Trajectory:',
    disabled=False
)
display(xyz_widget)

print "Trajectory:", xyz_widget.value
path_to_xyz = dir_name + "/traj_" + xyz_widget.value + ".xyz"
print "Path to xyz file:", path_to_xyz
traj = mda.Universe(path_to_xyz)
w = nv.show_mdanalysis(traj)
w<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.130279807520941, 'fraction_numerical': 0.011227945107823918, 'mean_word_length': 6.915373765867419, 'pattern_counts': {'":': 1, '<': 48, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '665952', 'license': 'MIT', 'n_tokens_mistral': 2107, 'n_tokens_neox': 2000, 'n_words': 419, 'path': 'examples/spawn_analysis.ipynb', 'repo_name': 'blevine37/pySpawn17', 'size': '5611'}