def test_getAllResults(self): mRes = ModelResult("test", './output') fieldComps = FieldComparisonList() fComp = FieldComparisonOp('TemperatureField') fieldComps.add(fComp) fResults = fieldComps.getAllResults(mRes) self.assertEqual(len(fResults), 1) self.assertEqual(fResults[0].fieldName, fComp.name) self.assertEqual(fResults[0].dofErrors[0], 0.00612235812)
def test_getAllResults(self): mRes = ModelResult("test", './output') fieldComps = FieldComparisonList() fComp = FieldComparisonOp('TemperatureField') fieldComps.add(fComp) fResults = fieldComps.getAllResults(mRes) self.assertEqual(len(fResults), 1) self.assertEqual(fResults[0].fieldName, fComp.name) self.assertEqual(fResults[0].dofErrors[0], 0.00612235812)
## Lesser General Public License for more details. ## ## You should have received a copy of the GNU Lesser General Public ## License along with this library; if not, write to the Free Software ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, ## MA 02110-1301 USA from credo.modelresult import ModelResult from credo.analysis.fields import FieldComparisonOp, FieldComparisonList from credo.io import stgcvg fComps = FieldComparisonList() fComps.add(FieldComparisonOp('VelocityField')) # TODO: perhaps should be an interface that doesn't require a full mRes? mRes = ModelResult("testMod", "./output/realistic") results = fComps.getAllResults(mRes) fr = results[0] fr.plotOverTime(show=True, dofIndex=0, path="./output/realistic") #Plotting #dofErrors = stgcvg.getDofErrors_ByDof( fr.cvgFileInfo ) #import matplotlib #matplotlib.use('Agg') #import matplotlib.pyplot as plt #plt.plot(dofErrors[0]) #plt.axhline(y=fr.tol, label='tolerance', linewidth=3, color='r') #plt.xlabel("Timestep") #plt.ylabel("Error vs analytic soln")
## Lesser General Public License for more details. ## ## You should have received a copy of the GNU Lesser General Public ## License along with this library; if not, write to the Free Software ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, ## MA 02110-1301 USA from credo.modelresult import ModelResult from credo.analysis.fields import FieldComparisonOp, FieldComparisonList from credo.io import stgcvg fComps = FieldComparisonList() fComps.add(FieldComparisonOp('VelocityField')) # TODO: perhaps should be an interface that doesn't require a full mRes? mRes = ModelResult("testMod", "./output/realistic") results = fComps.getAllResults(mRes) fr = results[0] fr.plotOverTime(show=True, dofIndex=0, path="./output/realistic") #Plotting #dofErrors = stgcvg.getDofErrors_ByDof( fr.cvgFileInfo ) #import matplotlib #matplotlib.use('Agg') #import matplotlib.pyplot as plt #plt.plot(dofErrors[0]) #plt.axhline(y=fr.tol, label='tolerance', linewidth=3, color='r') #plt.xlabel("Timestep") #plt.ylabel("Error vs analytic soln")
#!/usr/bin/env python import credo.jobrunner from credo.modelrun import ModelRun from credo.analysis.fields import FieldComparisonOp, FieldComparisonList mRun = ModelRun("CosineHillRotate", "CosineHillRotateBC.xml", "output/rotateAnalysis" ) mRun.writeInfoXML() jobRunner = credo.jobrunner.defaultRunner() mRes = jobRunner.runModel(mRun) mRes.writeRecordXML() #----------------------------- # Post-process fieldComps = FieldComparisonList() # Should there be an interface to get from result too? fieldComps.readFromStgXML(mRun.modelInputFiles, mRun.basePath) fieldComps.postRun(mRun, mRun.basePath) fCompResults = fieldComps.getAllResults(mRes) for res in fCompResults: print "Error for field '%s' was %s" % (res.fieldName, res.dofErrors) res.plotOverTime(show=True, path=mRes.outputPath) mRes.readFrequentOutput() mRes.freqOutput.plotOverTime('Time', show=True, path=mRes.outputPath) maxTime, maxTimeStep = mRes.freqOutput.getMax('Time') print "Maximum value of time was %f, at step %d" % (maxTime, maxTimeStep)