How to create a combined input file for Prestressed Modal Msup Transient analysis via script?
Rohith Patchigolla
Member, Moderator, Employee Posts: 218
✭✭✭✭
in Structures
I have a Static-Modal-Transient analysis which I want to run in the HPC Linux cluster. For this, I want to create a single input file. I do it currently manually and insert /rename command at the end of each input file to rename the rst of that particular analysis. How to automate this?
Tagged:
0
Answers
-
You can try the below script (run it in Mechanical Scripting Console or create a custom button in Mechanical) to create a combined input file saved in the user files directory of the project.
Please note that this is assuming your Static, Modal and Transient analysis are first, second and third analysis in the tree. If not, please adjust the index accordingly for all the three DataModel.AnalysisList[] commands.
import wbjn import os userfilesdir = wbjn.ExecuteCommand(ExtAPI,"""returnValue(GetUserFilesDirectory())""") combinedFile = "run.dat" staticFile = "static.dat" ModalFile = "Modal.dat" TransientFile = "Trans.dat" staticFilePath = os.path.join(userfilesdir,staticFile) modalFilePath = os.path.join(userfilesdir,ModalFile) transientFilePath = os.path.join(userfilesdir,TransientFile) StaticAnalysis = DataModel.AnalysisList[0] ModalAnalysis = DataModel.AnalysisList[1] TransientAnalysis = DataModel.AnalysisList[2] StaticAnalysis.WriteInputFile(staticFilePath) ModalAnalysis.WriteInputFile(modalFilePath) TransientAnalysis.WriteInputFile(transientFilePath) StaticEndCommands = """/rename,file,rst,,static,rst""" ModalEndCommands = """/rename,file,rst,,modal,rst""" TransientEndCommands = """/rename,file,rst,,transient,rst""" # List of input .dat files and the corresponding end text files = [staticFilePath, modalFilePath, transientFilePath] end_texts = [StaticEndCommands, ModalEndCommands, TransientEndCommands] with open(os.path.join(userfilesdir,combinedFile), 'w') as combined_file: for i, file in enumerate(files): with open(file, 'r') as f: combined_file.write(f.read()) combined_file.write("\n" + end_texts[i] + "\n")
0