Python script:
#!/usr/bin/env python # -*- coding: utf-8 -*- from optimization_tools import * for h in numpy.logspace(-2,-8,10): problem = "grad-test-h_" + str(h) xml = open_xml('filename.xml') #replace(xml, "//cfs:cfsSimulation/@id", str(h)) only if set in xml-file replace(xml, "//cfs:option[@name='difference_interval']/@value", str(h)) xml.write(problem + '.xml') cmd = 'cfs ' + problem #print(cmd) execute(cmd)
For the script to work the following has to be set in the xml-file:
<snopt> <option name="verify_level" type="integer" value="3"/> <option name="difference_interval" type="real" value="1e-5"/> </snopt>
One can postprocess the information by simple terminal tools:
grep ' 1 5.000000' *h*.snopt > diff_h.plot.dat
The string has to be the same as in the snopt file for the first gradient. The results can be plotted for example with gnuplot:
set logscale x plot "diff_h.plot.dat" u 4:7 , "diff_h.plot.dat" u 4:6
There was an error while loading. Please reload this page.