automation of saving Stress Date of each Simulation results with Query commends in TCL
hi, im simulating e-Motor with varias RPM. my goal is automation of Query of Stress Data at each RPM in csv File. and now i try to do it with 3 different RPMs.
i made a for-loop function to make Automation. the variable $subcase is for maximum stress of each simulation. and i just a other variable $i for query. and i got only lastest Stress data of rpm. which means i did simulation for 0, 10000, and 20000 RPMs . i got stress data only of 20000RPM. do you have some idea or should i fix some sentence in For Loop?
Thanks in Advanced
Answers
-
are you sure that the RPM is the subcase and not simulation?
Maybe this is what is not working, but it depends on your result file.
0 -
Adriano A. Koga_21884 said:
are you sure that the RPM is the subcase and not simulation?
Maybe this is what is not working, but it depends on your result file.
hey Adriano,
i made for look inside of foreach Loop. here u can see my TCL Code below.
i made variable i to compare with subcases(every simulation of different RPMs). every Stress Data of each RPM Simulation should be Saved. but now i have a new problem. i made simulations of 0, 10000, 20000 RPM. and it was saved but the Data of 3 txt file are Results of 20000RPM simulation result... i dont know why its like this. do you know reason? Thanks in Advanced
hwi GetSessionHandle sessionsession GetProjectHandle projectproject GetPageHandle page [project GetActivePage]page GetWindowHandle window [page GetActiveWindow]window GetClientHandle clientclient GetModelHandle model [client GetActiveModel]model GetResultCtrlHandle resultresult GetContourCtrlHandle contourcontour SetDataType "Element Stresses (2D & 3D)"contour SetDataComponent component vonMisescontour SetAverageMode advancedcontour SetLayer Maxcontour SetEnableState Truecontour SetResultSystem 0contour SetDimensionEnabled solid Truecontour SetDimensionEnabled shell Truecontour SetEnableState Trueclient GetMeasureHandle measure 1model GetQueryCtrlHandle myQueryNamemodel GetSelectionSetHandle mySetName [model AddSelectionSet node]mySetName Add alllappend max_stressset subcases [result GetSubcaseList "Base"]foreach subcase $subcases {result SetCurrentSubcase $subcase ;# nächsten Subcase auswählenclient Draw ;# refresh Viewfor {set i 0} {$i < $subcase} {incr i} {result SetCurrentSimulation $imyQueryName SetDataSourceProperty result datatype StressmyQueryName SetDataSourceProperty resuslt shelllayer UppermyQueryName SetQuery "node.id, node.coords, contour.value"myQueryName SetSelectionSet [mySetName GetID]myQueryName WriteData {D:/junhyeong/Spannungsdaten/test.txt}file rename -force /junhyeong/Spannungsdaten/test.txt /junhyeong/Spannungsdaten/${i}.txt}lappend max_stress [measure GetMaximum scalar] ;# Maximum an Liste anhängen}# Export der maximalen Spannungenset responses_file [open "struct_responses.json" "w"]set line "\["append line [join $max_stress ", "]append line "\]"puts -nonewline $responses_file $lineclose $responses_file0 -
Junhyeong Kang said:
hey Adriano,
i made for look inside of foreach Loop. here u can see my TCL Code below.
i made variable i to compare with subcases(every simulation of different RPMs). every Stress Data of each RPM Simulation should be Saved. but now i have a new problem. i made simulations of 0, 10000, 20000 RPM. and it was saved but the Data of 3 txt file are Results of 20000RPM simulation result... i dont know why its like this. do you know reason? Thanks in Advanced
hwi GetSessionHandle sessionsession GetProjectHandle projectproject GetPageHandle page [project GetActivePage]page GetWindowHandle window [page GetActiveWindow]window GetClientHandle clientclient GetModelHandle model [client GetActiveModel]model GetResultCtrlHandle resultresult GetContourCtrlHandle contourcontour SetDataType "Element Stresses (2D & 3D)"contour SetDataComponent component vonMisescontour SetAverageMode advancedcontour SetLayer Maxcontour SetEnableState Truecontour SetResultSystem 0contour SetDimensionEnabled solid Truecontour SetDimensionEnabled shell Truecontour SetEnableState Trueclient GetMeasureHandle measure 1model GetQueryCtrlHandle myQueryNamemodel GetSelectionSetHandle mySetName [model AddSelectionSet node]mySetName Add alllappend max_stressset subcases [result GetSubcaseList "Base"]foreach subcase $subcases {result SetCurrentSubcase $subcase ;# nächsten Subcase auswählenclient Draw ;# refresh Viewfor {set i 0} {$i < $subcase} {incr i} {result SetCurrentSimulation $imyQueryName SetDataSourceProperty result datatype StressmyQueryName SetDataSourceProperty resuslt shelllayer UppermyQueryName SetQuery "node.id, node.coords, contour.value"myQueryName SetSelectionSet [mySetName GetID]myQueryName WriteData {D:/junhyeong/Spannungsdaten/test.txt}file rename -force /junhyeong/Spannungsdaten/test.txt /junhyeong/Spannungsdaten/${i}.txt}lappend max_stress [measure GetMaximum scalar] ;# Maximum an Liste anhängen}# Export der maximalen Spannungenset responses_file [open "struct_responses.json" "w"]set line "\["append line [join $max_stress ", "]append line "\]"puts -nonewline $responses_file $lineclose $responses_fileLike I mentioned before, you need to take care with the difference of 'subcase' and 'simulation'.
Make sure that you're changing the correct one inside your loop.
Additionally, you could much easily use HWC commands for some of these commands, except the query.
0