[PYTHON] Get OCTA simulation conditions from a file and save with pandas

How to save simulation conditions as a CSV file

When using OCTA, I really want to list and save my settings. Since it is troublesome to start gourmet every time and see it, I made it possible to save some settings as a CSV file. It's a simple way. I put the condition in a variable, make it a series with Pandas, make the series into a data frame, and then save it.

ʻUDFManagerImporting this module will allow you to work with UDF files in Python using OCTA features. Create an instance of the UDF file with ʻudf = UDFManager (file_name). ʻUdf.get (location) `returns the data held by the location in the UDF as an argument. For location at this time, write the UDF path name.

from UDFManager import UDFManager
import pandas as pd
import numpy as np
import os
path = "c:\path"
files = os.listdir(path)
filename = "filename_out.bdf"
openfile = path + '/' + filename
udf = UDFManager(openfile)
print(udf)

#dynamics_conditions
#time
max_force = udf.get('Simulation_Conditions.Dynamics_Conditions.Max_Force')
delta_t = udf.get('Simulation_Conditions.Dynamics_Conditions.Time.delta_T')
total_steps = udf.get('Simulation_Conditions.Dynamics_Conditions.Time.Total_Steps')
output_interval_steps = udf.get('Simulation_Conditions.Dynamics_Conditions.Time.Output_Interval_Steps')

time_list = (max_force,delta_t,total_steps,output_interval_steps)
time_list_s = pd.Series(time_list, index=['Max_Force', 'Time.delta_T', 'Time.Total_Steps','Time.Output_Interval_Steps'])

#temp
temperature = udf.get('Simulation_Conditions.Dynamics_Conditions.Temperature.Temperature')
interval_of_scale_temp = udf.get('Simulation_Conditions.Dynamics_Conditions.Temperature.Interval_of_Scale_Temp')

temp_list = (temperature,interval_of_scale_temp)
temp_list_s = pd.Series(temp_list,index=['Temperature','Temperature.Interval_of_Scale_Temp'])


#pressure
pressure = udf.get('Simulation_Conditions.Dynamics_Conditions.Pressure_Stress.Pressure')
stress_xx = udf.get('Simulation_Conditions.Dynamics_Conditions.Pressure_Stress.Stress.xx')
stress_yy = udf.get('Simulation_Conditions.Dynamics_Conditions.Pressure_Stress.Stress.yy')
stress_zz = udf.get('Simulation_Conditions.Dynamics_Conditions.Pressure_Stress.Stress.zz')
stress_yz = udf.get('Simulation_Conditions.Dynamics_Conditions.Pressure_Stress.Stress.yz')
stress_zx = udf.get('Simulation_Conditions.Dynamics_Conditions.Pressure_Stress.Stress.zx')
stress_xy = udf.get('Simulation_Conditions.Dynamics_Conditions.Pressure_Stress.Stress.xy')

stress_list = (pressure,stress_xx,stress_yy,stress_zz,stress_yz,stress_zx,stress_xy)
stress_list_s = pd.Series(stress_list,index=['Pressure','Stress.xx','Stress.yy','Stress.zz','Stress.yz','Stress.zx','Stress.xy'])

#solver
solver_type = udf.get('Simulation_Conditions.Solver.Solver_Type')
dynamics_algorithm = udf.get('Simulation_Conditions.Solver.Dynamics.Dynamics_Algorithm')

solver_list = (solver_type,dynamics_algorithm)
solver_list_s = pd.Series(solver_list,index=['Solver_Type','Dynamics_Algorithm'])

#Boundary_Conditions
boundary_conditions_a_axis = udf.get('Simulation_Conditions.Boundary_Conditions.a_axis')
boundary_conditions_b_axis = udf.get('Simulation_Conditions.Boundary_Conditions.b_axis')
boundary_conditions_c_axis = udf.get('Simulation_Conditions.Boundary_Conditions.c_axis')
boundary_conditions_periodic_bond = udf.get('Simulation_Conditions.Boundary_Conditions.Periodic_Bond')

boundary_conditions_list = (boundary_conditions_a_axis,boundary_conditions_b_axis,boundary_conditions_c_axis,boundary_conditions_periodic_bond)
boundary_conditions_list_s = pd.Series(boundary_conditions_list,index=['a_axis','b_axis','c_axis','Periodic_Bond'])


#Calc_Potential_Flags.Bond
calc_potential_flags_bond = udf.get('Simulation_Conditions.Calc_Potential_Flags.Bond')
calc_potential_flags_angle = udf.get('Simulation_Conditions.Calc_Potential_Flags.Angle')
calc_potential_flags_torsion = udf.get('Simulation_Conditions.Calc_Potential_Flags.Torsion')
calc_potential_flags_non_bonding_interchain = udf.get('Simulation_Conditions.Calc_Potential_Flags.Non_Bonding_Interchain')
calc_potential_flags_non_bonding_intrachain = udf.get('Simulation_Conditions.Calc_Potential_Flags.Non_Bonding_Intrachain')
calc_potential_flags_non_bonding_1_3 = udf.get('Simulation_Conditions.Calc_Potential_Flags.Non_Bonding_1_3')
calc_potential_flags_non_bonding_1_4 = udf.get('Simulation_Conditions.Calc_Potential_Flags.Non_Bonding_1_4')
calc_potential_flags_external = udf.get('Simulation_Conditions.Calc_Potential_Flags.External')
calc_potential_flags_electrostatic = udf.get('Simulation_Conditions.Calc_Potential_Flags.Electrostatic')
calc_potential_flags_tail_correction = udf.get('Simulation_Conditions.Calc_Potential_Flags.Tail_Correction')

calc_potential_list = (calc_potential_flags_bond, calc_potential_flags_angle,calc_potential_flags_torsion,
								calc_potential_flags_non_bonding_interchain,calc_potential_flags_non_bonding_intrachain,calc_potential_flags_non_bonding_1_3,
								calc_potential_flags_non_bonding_1_4,calc_potential_flags_external,calc_potential_flags_electrostatic,calc_potential_flags_tail_correction)

calc_potential_list_s = pd.Series(calc_potential_list,index=['Bond','Angle','Torsion','Non_Bonding_Interchain','Non_Bonding_Intrachain','Non_Bonding_1_3',
								'Non_Bonding_1_4','External','Electrostatic','Tail_Correction'])

#Output_Flags_is_no_count
#Initial_Structure
initial_unit_cell_density = udf.get('Initial_Structure.Initial_Unit_Cell.Density')
initial_unit_cell_cell_size_a = udf.get('Initial_Structure.Initial_Unit_Cell.Cell_Size.a')
initial_unit_cell_cell_size_b = udf.get('Initial_Structure.Initial_Unit_Cell.Cell_Size.b')
initial_unit_cell_cell_size_c = udf.get('Initial_Structure.Initial_Unit_Cell.Cell_Size.c')
initial_unit_cell_cell_size_alpha = udf.get('Initial_Structure.Initial_Unit_Cell.Cell_Size.alpha')
initial_unit_cell_cell_size_beta = udf.get('Initial_Structure.Initial_Unit_Cell.Cell_Size.beta')
initial_unit_cell_shear_strain = udf.get('Initial_Structure.Initial_Unit_Cell.Shear_Strain')
initial_unit_cell_density = udf.get('Initial_Structure.Initial_Unit_Cell.Density')

initial_unit_cell_list = (initial_unit_cell_density, initial_unit_cell_cell_size_a,initial_unit_cell_cell_size_b,
								initial_unit_cell_cell_size_c ,initial_unit_cell_cell_size_alpha,initial_unit_cell_cell_size_beta,
								initial_unit_cell_shear_strain,initial_unit_cell_density)

initial_unit_cell_list_s = pd.Series(initial_unit_cell_list,index=['Density','Cell_Size.a','Cell_Size.b','Cell_Size.c','Cell_Size.alpha','Cell_Size.beta',
								'Shear_Strain','Density'])

#generated_method
generate_method_method= udf.get('Initial_Structure.Generate_Method.Method')
relaxation= udf.get('Initial_Structure.Relaxation.Relaxation')
relaxation_method= udf.get('Initial_Structure.Relaxation.Method')

generated_method_list = (generate_method_method, relaxation,relaxation_method)

generated_method_list_s = pd.Series(generated_method_list,index=['Method','Relaxation','Relaxation.Method'])

octa_pd = pd.concat([time_list_s, temp_list_s,stress_list_s,solver_list_s, boundary_conditions_list_s, calc_potential_list_s,initial_unit_cell_list_s,generated_method_list_s],axis=0)

savefile = path + '/' + filename + 'setteing_info.csv'

octa_pd.to_csv(savefile)









Recommended Posts

Get OCTA simulation conditions from a file and save with pandas
Get data from MySQL on a VPS with Python 3 and SQLAlchemy
Read and format a csv file mixed with comma tabs with Python pandas
Extract lines that match the conditions from a text file with python
Get the average salary of a job with specified conditions from indeed.com
Python --Get bitcoin rate BTC / JPY from bitflyer at regular intervals and save it to a file
Save the object to a file with pickle
Draw a graph with matplotlib from a csv file
Read line by line from a file with Python
Save the setting conditions as a CSV file using UDF Manager in OCTA
Python-Read data from a numeric data file and calculate covariance
Get mail from Gmail and label it with Python3
Build a Docker container and save png from altair
[Python] Start a batch file from Python and pass variables.
Create a decision tree from 0 with Python and understand it (3. Data analysis library Pandas edition)
Get an image from a web page and resize it
Save the pystan model and results in a pickle file
Let's use COTOHA and get a good message from Pokemon ▼
Make a gif animation from a serial number file with matplotlib
Hash with python and escape from a certain minister's egosa
Make a BLE thermometer and get the temperature with Pythonista3
Get Japanese stock price information from yahoo finance with pandas
Read and write a file
Let's create a tic-tac-toe AI with Pylearn 2-Save and load models-
Create a temporary file with django as a zip file and return it
Process Splunk execution results using Python and save to a file
Correspondence analysis of sentences with COTOHA API and save to file
Save the Pydrive authentication file in a different directory from the script
Read a file in Python with a relative path from the program
[Python3] Save the mean and covariance matrix in json with pandas
Operate Firefox with Selenium from python and save the screen capture
DataFrame of pandas From creating a DataFrame from two lists to writing a file
Create and return a CP932 CSV file for Excel with Chalice
Get video file information with ffmpeg-python
Create a pandas Dataframe from a string.
Build a deb file with Docker
Get one column from DataFrame with DataFrame
Save and retrieve files with Pepper
Draw a graph with pandas + XlsxWriter
Save a YAML-formatted file in PyYAML
Create a file uploader with Django
2. Make a decision tree from 0 with Python and understand it (2. Python program basics)
Replace the directory name and the file name in the directory together with a Linux command.
Face detection from multiple image files with openCV, cut out and save
Tips: [Python] Randomly restore and extract an array from a fasta file
Get tweets with Google Cloud Function and automatically save images to Google Photos
From pandas1.0.0, you can specify S3 / GCS URL with read_pickle () and to_pickle ()!
Make a decision tree from 0 with Python and understand it (4. Data structure)
Create a decision tree from 0 with Python and understand it (5. Information Entropy)