TAGGED: ansys-apdl, harmonic
-
-
May 31, 2023 at 8:37 pmMd_SalemSubscriber
Hi evey one
I used the next code to extract the potential energy of harmonic analysis (10 steps) for some parts of structure simulated with element 185 .
*DIM,energy_array,ARRAY,10
/POST1
i=1
*DO, step, 1,19, 2
SET,,,,,,,STEP ! store results for set step
ESEL,S,ENAME,,185
ETABLE,ENERGY,SENE
SSUM
*GET,my_energy,SSUM,,ITEM,ENERGY
energy_array(i)= my_energy
*CFOPEN,ENERGIES,txt,C:\Users\MD\Desktop
*VWRITE,energy_array
%(F18.10)
*CFCLOS
ETABLE,CLEAR
ALLSEL
i=i+1
*ENDDOUnfortunately the file ENERGIES.txt is created but empty !!!
Also I need to set parameter "my_energy" to record the highst value of the harmonic steps rather than recording last step as this code do.
would any one help me with that code ?
Regards
-
June 1, 2023 at 10:00 amMd_SalemSubscriber
I solved the first problem by using *MWRITE command after the DO loop and it worked properly.
Still the second problem for me : how to set parameter “my_energy” to the highest value of the steps :
*DIM,energy_array,ARRAY,10
/POST1
i=1*DO, step, 1,19, 2
set,,,,,,,step ! store results for set step
ESEL,S,ENAME,,185
etable,energy,sene
ssum*get,my_energy,ssum,,ITEM,energy
energy_array(i)= my_energy
ETABLE,CLEAR
ALLSEL
i=i+1
*ENDDO*MWRITE,energy_array,C:\Users\MD\Desktop\ENERGIES,TXT
(F18.10)Regads
-
June 1, 2023 at 12:56 pmChandra SekaranAnsys Employee
1) On issue 1 I think *VWRITE should also work if you use the starting index number like below. Also I am notsure what the % sign is on the format so I removed it.
*CFOPEN,ENERGIES,txt,C:\Users\MD\Desktop
*VWRITE,energy_array(1)
(F18.10)
*CFCLOS2) I am not sure what you mean by "the highst value of the harmonic steps rather than recording last step as this code do." Let us say you requested harmonic excitation frequency between 10 and 15 Hz and asked for 5 equally spaced steps. You will get 5 solutions at 11,12,13,14,15 Hz. Can you explain your question in this scenario?
-
June 2, 2023 at 4:09 pmMd_SalemSubscriberHi Chandra,I apologise for any confusion.I mean that the parameter "my_energy" continues changing at each step in the displayed *DO loop. However, it retains the value of the last step of the SENE energy. I need the parameter "my_energy" to hold the maximum value over *DO loop steps.In other words, assuming the values of "my_energy" at the five steps you provided are 1.1, 1.2, 1.3, 1.1, and 0.9, respectively, the final value of "my_energy" in the supplied code should be 0.9. I require the maximum value, which is "1.3" I hope that makes sense.Regards
-
-
June 2, 2023 at 9:19 amClaudio PedrazziSubscriber
Concerning the question about getting the maximum value, if I understand correctly, the problem is that everytime you go through the loop, you overwrite my_energy. I would simply use an additional storage variable like max_my_energy and initialise it to 0 before the loop begins, then in every step you should simply compare my_energy with the maximum until there, and if higher, substitute it.
*IF,my_energy,GT,max_my_energy,THEN
max_my_energy=my_energy
*ENDIF
-
June 2, 2023 at 12:26 pmChandra SekaranAnsys Employee
Oh I see. I did not catch on to what you meant. Yes, the above should work.
-
June 2, 2023 at 4:42 pmChandra SekaranAnsys Employee
If you have the array energy_array filled then you can also use (outside the loop) "*VSCFUN,maxval,MAX,energy_array(1) " . This will return the maximum value and store it in APDL parameter maxval.
-
- The topic ‘How to write an array to text file ?’ is closed to new replies.
- Problem with access to session files
- Ayuda con Error: “Unable to access the source: EngineeringData”
- At least one body has been found to have only 1 element in at least 2 directions
- Error when opening saved Workbench project
- Geometric stiffness matrix for solid elements
- How to select the interface delamination surface of a laminate?
- How to apply Compression-only Support?
- Timestep range set for animation export
- SMART crack under fatigue conditions, different crack sizes can’t growth
- Image to file in Mechanical is bugged and does not show text
-
1191
-
513
-
488
-
225
-
209
© 2024 Copyright ANSYS, Inc. All rights reserved.