Matlab optimization with Ansys APDL
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I need to do a bearings arrangement optimization on a shaft. For this master thesis work i use Matlab to write a FEMin.txt file containing all the Ansys APDL commands, after the writing of this input file MATLAB should launch the Ansys solver, read the macro, write the results.txt file, read the file and perform an multiobj optimization. The main problem of my script is when I call the Ansys solver, no results file was written. If I launch Ansys apdl from my desktop icon and select: file->read input from-> FEMin.txt the program do what I want, perform the analysis and write the results.txt file in the right folder, so i think that the macro file is correct.
I tried this commands to run ansys by matlab:
1)first command i tried
system('SET KMP_STACKSIZE=10240k & "C:\Program Files\ANSYS Inc\ANSYS Student\v195\ANSYS\bin\winx64\ANSYS195.exe" -b -i "FEMin.txt" -o "FEMout.txt"');
set KMP_STACKSIZE to 10240k to avoid memory to run out, than i run the Ansys solver in bach mode (-b) and specified the input file (-i) and the output file (-o)
when i run this command only input and output files were written, reading the FEMout.txt file the simulation seems to be done but ansys can't output the results.txt file...
2)second command i tried
This time i use the ansys launcher to set the user preference like ammount of memory, directory ecc. and going to option->display the command line i copy the command :
system('"C:\Program Files\ANSYS Inc\ANSYS Student\v195\ansys\bin\winx64\MAPDL.exe" -g -p aa_t_i -smp -np 2 -lch -dir "C:\Users\ALIENWARE\Desktop\simulation_fem" -j "file" -s read -m 10240 -db 10240 -l en-us -t -d win32 -b -i FEMin.txt -o FEMout.txt')
this command works like the command above, perform simulation but no results.txt file is write.
I read in other threads that STACKSIZE could be the problem but i have allready set the STACKSIZE over the default 512K when launching the ansys solver.
Another problem is that calling the ansys solver every time that i write a macro slow down my otimization. In ansys environment if i read the input file form FEMin.txt the simulation takes only 0,7s to be done including writting the results file! Maybe there is another way to run my optimization faster?
I hope someone can give me some advise to solve my problem.
ps, I'm using Ansys 19r3 and Matlab R2019b,
i have performed CFD optimization in the same way with Fluent (system(['"C:\Program Files\ANSYS Inc\ANSYS Student\v195\fluent\ntbin\win64\fluent.exe" 2ddp -t4 -g -i Journal_Fluent.jou'])) and i haven' t this input reading problem..
2 comentarios
Pedro Pesante Castro
el 14 de Jun. de 2021
Hi Cristian, how has resulted your job?
I'm trying to optimize some material properties into a APDL script using MATLAB, in order to adjust (minimize error) with the experimental results.
Can you share some information about your project with me? What type of optimization algorithm has you used?
Regards
Respuestas (2)
yu tian
el 30 de En. de 2020
Hey boy, I am very interesting in your problem, and there are some advice I will give to you, maybe it will be useful to you.
Problem one: no results.txt file is write.
Advice one: you must write down the APDL command in your "FEMin.txt", you can get some information about the command "*vwrite" , then your data or parameters which are produced in the process of ANSYS can be write in the results.txt , after that you can read the results.txt to your matlab. And the two command you tried are both OK.
Problem two: slow down optimization
Advice two: To be honest, I find it too and I dont know how to run it faster, an alternative method is to use the ";" to avoid the command window output of matlab, the optimization process may be faster than it not apply. Meanwhile, I am finding some approaches to solve this drawback, if you have some novel advice or method, welcome to share it with me.
I hope these words can be useful to you, good luck.
1 comentario
ferdaous TRIBAK
el 24 de Nov. de 2022
Hi Yu Tian, can you help me to solve my problem? I made a simulation in ansys workbench; then I transferred it to APDL. Now I need to link it to matlab so I can work on the optimization, can you give me a hand?
Ver también
Categorías
Más información sobre Graphics Performance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!