🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Query automation of Reults of Simulations

hi, I m simulating a model of a rotating e-motor and solved the model with different speeds with OptiStruct (as different loadsteps / loadcols). im already done to do automation of Query Stress Data in every nodes. But i want to query more than just one Simulations result. for example i need Stress Data of from 1RPM to 20000RPM, which means 20000 Simulations Results should be reported. i did automation with tcl Commends

 

hwi GetSessionHandle session
session GetProjectHandle project
project GetPageHandle page [project GetActivePage]
page GetWindowHandle window [page GetActiveWindow]
window GetClientHandle client
client GetModelHandle model [client GetActiveModel]
model GetResultCtrlHandle result
 
result GetContourCtrlHandle contour
 
contour SetDataType "Element Stresses (2D & 3D)"
contour SetDataComponent component vonMises
contour SetAverageMode advanced
contour SetLayer Max
contour SetEnableState True
contour SetResultSystem 0
contour SetDimensionEnabled solid True
contour SetDimensionEnabled shell True
contour SetEnableState True
 
client GetMeasureHandle measure 1
 
lappend max_stress
set subcases [result GetSubcaseList "Base"]
foreach subcase $subcases {
result SetCurrentSubcase $subcase                  ;# nächsten Subcase auswählen
client Draw                                        ;# refresh View
lappend max_stress [measure GetMaximum scalar]     ;# Maximum an Liste anhängen
}
 
# Export der maximalen Spannungen
set responses_file [open "struct_responses.json" "w"]
set line "\["
append line [join $max_stress ", "]
append line "\]"
puts -nonewline $responses_file $line
close $responses_file
 
 
# Export der Spannungen
model GetQueryCtrlHandle myQueryName
model GetSelectionSetHandle mySetName [model AddSelectionSet  node]
mySetName Add all
result SetCurrentSimulation 1
 
 
 
myQueryName SetDataSourceProperty result datatype Stress
myQueryName SetDataSourceProperty result shelllayer Upper
myQueryName SetQuery "node.id, node.coords, contour.value"
myQueryName SetSelectionSet [mySetName GetID];
myQueryName WriteData {D:/junhyeong/Spannungsdaten/Daten.csv};
 
when i do simulation of different RPMs like 10000 15000 17000 and 20000, only Stress Data of 20000(biggest RPM Stressdata i guess) ist reported. but i need all Stress Data. what i miss it from TCL Commends or do you guys have ideas?

thanks

Find more posts tagged with

Sort by:
1 - 2 of 21

    you would need to perform a loop (for) looping over all your rotations (probably readed as simulations)

    So, here, instead of performing only for the current simulation (1), you would need a loop for all of them

    for 1...number_of_sim   {

    ...

    mySetName Add all
    result SetCurrentSimulation $i
     
    #query commands, and set to different name, according to the RPM
     
    }
     
    To help reduce the effort here, you could maybe use a mixed combination of TCL and HWC commands. Except for query, they work like a charm.
     

    https://community.altair.com/community/en/develop-and-deploy-your-custom-solutions-faster-with-hyperworks-2022-1?id=kb_article&sys_id=f114507d1b30d910507ca6442a4bcb0b

    you would need to perform a loop (for) looping over all your rotations (probably readed as simulations)

    So, here, instead of performing only for the current simulation (1), you would need a loop for all of them

    for 1...number_of_sim   {

    ...

    mySetName Add all
    result SetCurrentSimulation $i
     
    #query commands, and set to different name, according to the RPM
     
    }
     
    To help reduce the effort here, you could maybe use a mixed combination of TCL and HWC commands. Except for query, they work like a charm.
     

    https://community.altair.com/community/en/develop-and-deploy-your-custom-solutions-faster-with-hyperworks-2022-1?id=kb_article&sys_id=f114507d1b30d910507ca6442a4bcb0b

    hey Adriano thanks for the Reply. now i try to make a Loop. i understood that i have to change on the line 'result SetCurrentSimulation 1' to 'result SetCurrentSimulation $i' but i dont get it what i have to also change on the Query lines. how can i make query to depend on the RPM? or what do you mean by 'set to different name'? And try to make 'for' loop like for {set i 0} {$i <5} {incr i}. and i ran the simulations for 10000 15000 20000 22000 RPMs but it is not exported..

     

    # Export der Spannungen
    model GetQueryCtrlHandle myQueryName
    model GetSelectionSetHandle mySetName [model AddSelectionSet  node]
    mySetName Add all
    result SetCurrentSimulation $i

     

    myQueryName SetDataSourceProperty result datatype Stress
    myQueryName SetDataSourceProperty result shelllayer Upper
    myQueryName SetQuery "node.id, node.coords, contour.value"
    myQueryName SetSelectionSet [mySetName GetID];
    myQueryName WriteData {D:/junhyeong/Spannungsdaten/Daten.csv};

     

    for {set i 0} {$i < 4} {incr i}