How do I link Matlab for controlling/automating pre- and post-processing of Simulation Data on Linux/Windows
1 view (last 30 days)
Show older comments
How do I link Matlab for controlling/automating pre- and post-processing of Simulation Data on Linux/Windows
Hello Community,
I am trying to create a Matlab script which controls/automates a pre-processing (Matab script) --> Simulation (Liggghts) --> post-processing (Matlab script) environment on Linux or Windows (preferably Linux).
I want to create a main-script or via Matlab-Livelink a Programm, which when running, starts different tasks once the previous task has finished. All the input and output data is in the same directory.
I use a Particle-Simulation-Software called LIGGGHTS for my Simulations. Liggghts uses .txt type files for input.
CURRENT STATE:
- In order to create Input files for Liggghts, i use a script generator function (Generate_input_script.m) on Matlab which generates a .txt file. This script generator is called via a (main.m) function, which contains material properties and parameters. In this .txt file, there are general informations about the simulations and most importantly material parameters.
- This .txt file is then read in manually to Liggghts through Terminal (Linux).
- After the Simulation ends, Liggghts spits out 3 output files (which i had ordered it to do so inside the input script).
- These output files are then run through a second Matlab script (Analysis.m) which is not in main.m, but run separately. This script analyses the output data from liggghts. The script is run manually.
AUTOMATED PROCESS: (See Image)
- Start main.m --> main.m starts Generate_input_script.m function
- Generate_input_script.m generates "input.name.txt" file
- Once the input script is generated, main.m should start Liggghts and read "input.name.txt" file in Liggghts
4/5. After Liggghts generates 3 different output files (output.1.txt / output.2.txt / output.3.txt), main.m should start Analysis.m script and read in the 3 output files.
The goal of the automation process, is to make it easier for me once doing simulations. Currently, every Processing step has to be done manually. The goal is to automate this process. for someone who has little experience in automation, where should i look to learn the principles of these kind of automations?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1364963/image.png)
Thank you very much in advance!
0 Comments
Answers (1)
Ayush
on 16 Aug 2023
Edited: Ayush
on 16 Aug 2023
To automate the process of controlling and automating pre- and post-processing of simulation data in MATLAB on Linux or Windows, you can follow these steps:
1. The main MATLAB script (`Main.m`) will serve as the entry point for your automation process. This script will call other functions and scripts as needed.
2. Call "generate_input_script.m" which should take the necessary parameters and material properties as inputs and write them to a text file (e.g., `input.name.txt`) .
3. In your `main.m` script, after calling `Generate_input_script.m`, you can use the `system` function in MATLAB to run LIGGGHTS with the generated input script. For example, you can use the following command in MATLAB to run LIGGGHTS in Linux:
system('liggghts -in input.name.txt');
This command executes the LIGGGHTS command-line tool with the specified input script.
4. After running LIGGGHTS, you can use the `system` function again to wait for the simulation to finish before proceeding to the next step. For example:
system('wait');
This command makes MATLAB wait until the LIGGGHTS process completes before moving on to the next line of code.
5. Once LIGGGHTS has finished running, you can proceed to post-process the output files. Call `Analysis.m` that reads and analyzes the output files generated by LIGGGHTS. You can use MATLAB's file I/O functions to read the output files and perform the desired analysis.
6. You can repeat steps 2-5 for each simulation you want to run. Modify the input parameters and material properties as needed for each simulation.
Hope this helps.
0 Comments
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!