Wenn ich OCTA verwende, möchte ich meine Einstellungen wirklich auflisten und speichern. Da es schwierig ist, jedes Mal Gourmet zu starten und es zu sehen, habe ich es möglich gemacht, einige Einstellungen als CSV-Datei zu speichern. Es ist ein einfacher Weg. Ich füge die Bedingung in eine Variable ein, mache daraus eine Serie mit Pandas, mache die Serie zu einem Datenrahmen und speichere sie dann.
UDFManager
Durch den Import dieses Moduls können Sie mit UDF-Dateien in Python mithilfe von OCTA-Funktionen arbeiten.
Erstellen Sie eine Instanz der UDF-Datei mit udf = UDFManager (Dateiname)
.
udf.get (location)
gibt die von location in UDF gehaltenen Daten als Argument zurück. Schreiben Sie für den Standort zu diesem Zeitpunkt den UDF-Pfadnamen.
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)