One provides here an example for the reading of optimization results. The first steps of the example consists in the creation of a NastranDb object, and the attachment of an XDB file:
db=NastranDb.new()
db.Name="tmpDB"
#~ db.readBdf("../../MODEL/EXEC_XDB/sol200_a.bdf")
xdbFileName="../../MODEL/EXEC_XDB/sol200_a.xdb"
#~ xdbFileName="../../MODEL/EXEC_XDB/sol200_b.xdb"
db.attachXdb(xdbFileName)
Note that the reading of the Nastran finite element model from a BDF file is not necessary to access optimization results.
Two optimization runs are provided in the Nastran examples:
“sol200_a.bdf” for an optimization with design variables.
“sol200_b.bdf” for a topometric optimization.
The two runs lead to similar kinds of outputs, including the history of design variables. However, the topometric optimization generates automatically design variables (for example, one variable per element). Then, the numbering of design variables can be awkward.
The printing of design variables history is done with the following ruby instructions:
x=db.getAttachmentDesVarHistory(xdbFileName,nil,nil)
STDOUT.printf("%14s%14s%14s\n","STEP","DVID","VALUE")
x.each do |tab|
STDOUT.printf("%14d%14d%14f\n",tab[0],tab[1],tab[2])
end
In this case, the history of all design variables, and for all steps. (“nil” values are passed for corresponding arguments of the “getAttachmentDesVarHistory” method.) Doing the same with the “sol200_b.xdb” file will yield a very long output as the number of design variables can be very large for topometric optimization.
The definition of constraints is printed as follows:
x=db.getAttachmentConstrDefinitions(xdbFileName)
STDOUT.printf("%8s%8s%8s%8s%8s%14s\n","IDCID","DCID","IRID","TYPE","LUFLAG","BOUND")
x.each do |tab|
str=""
if tab[4]==1 then
str=">"
elsif tab[4]==2 then
str="<"
end
STDOUT.printf("%8d%8d%8d%8d%8s%14f\n",tab[0],tab[1],tab[2],tab[3],str,tab[5])
end
And the corresponding histories are obtained as follows:
x=db.getAttachmentConstrHistory(xdbFileName)
STDOUT.printf("%8s%8s%14s\n","STEP","IDCID","VALUE")
x.each do |tab|
STDOUT.printf("%8d%8d%14f\n",tab[0],tab[1],tab[2])
end
Here, the history is printed for all optimization steps, as the corresponding parameter is not provided.
And similarly, the objective history is printed as follows:
x=db.getAttachmentObjectiveHistory(xdbFileName)
STDOUT.printf("%8s%14s%8s%14s\n","STEP","OBJ.","IRID","Cst. VALUE")
x.each do |tab|
STDOUT.printf("%8d%14f%8d%14f\n",tab[0],tab[1],tab[2],tab[3])
end
Note that when a topometric optimization is calculated by Nastran as a design variable optimization. (Nastran defines automatically one design variable per element.)
The example is provided in file "RUBY/EX21/printSol200Infos.rb".