creating stress response with flexibel element range
hello
i would like to create an optimization approach in hyperstudy. i use a tcl-script based model file with parametrized geometry to generate my .fem model. the objective is to minimize the geometry till a certain stress level is reached. i define my stress response with the 'max(resvector(...))' function.
this works well, but due to the changing geometry in the optimization approach, the script use a criteria-based automesh function to obtain a good element quality. as a result, the total number of elements varies and i get a error message 'index out of range' for 'resvector' if the number of elements are below the end_request arguement of the function. so i want to implement some kind of automated element range function (minimum to maximum element index) into the 'resvector' function.
question: is it possible to include a dynamic range of elements into the 'resvector' function?
[f.e. 'resvector(file_name, type, 0 [start_request], maximum element index [end_request], ...)']
greetings
stefan
Answers
-
Hi Stefan
If you can create responses that gets the minimum element index and maximum element index, you can use these responses in your resvector definition such as
max(resvector(getenv('HST_APPROACH_RUN_PATH') + '/m_1/beam.h3d',1,0,r_6,0,0,0,1))
In this example, minimum element index is always 0 but maximum element index is another response (r_6). This response, r_6, in this case, reads the number of elements from the OptiStruct output file.
Hope this helps
Fatma
0 -
Hello Stefan,
To add to the above reply from Fatma: you could define something like r_6 using a HyperMath function like:
function getNumReqs(fileName,type_index,subcase)
s = GetSubcase(fileName,subcase+1)
numReqs=s::GetNumReqs(type_index+1)
return numReqs
endThis function can be registered for use in HyperStudy making it accesible just like any other function. So for example after registering it, you would define r_6 to have the expression :
getNumReqs(getenv('HST_APPROACH_RUN_PATH') + '/m_1/beam.h3d',1,0) where 1 and 0 are the Type and Subcase referenced by resvector.
Thanks
Joe
0 -
Hello Fatma and Joe
Thanks a lot for your help. My solution: As Fatma has been suggested, I create a new response (element_max) to get the maximum element index. For that purpose, I use the 'ASCII Extracts' function in the expression builder, with the .out as file source (where I can find the total number of elements) and use the keyword 'Elements : ' to define my response.
It´s then 'max(resvector(getenv('HST_APPROACH_RUN_PATH')+'FILENAME',1,0, element_max-1,0,0,0,0))'. -1 because the index starts with 0!
It´s not as pretty as Joe's hint, but it works fine for me.
Stefan0