#This example repeats the example from Mathematica. Look at #FirstOrderSystem.nb.pdf in the parent directory: there are more comments there. #Setting Up Directory and Loading Functions import os os.chdir('.') print 'current directory is', os.getcwd() #in order for import to work post4mor.py should be in: # the directory in which python has started, or # Python25/Lib/site-packages, or # on the path import sys sys.path.append('.') from post4mor import * filePath = '../ex/' #we need the second argument True to force removing of empty lines #produced by MOR for ANSYS sys = ReadSystem(filePath + 'thruster', True) #Transient Simulation ansys = ReadResult(filePath + 'thruster.transient') #subsection Using NDSolve with TransientSolution Function is skipped #as there is no NDSolve in Python #Using Ansys Integrator with AnsysTransientSolution Function res25 = AnsysTransientSolution(XSeries(ansys), sys) res5 = AnsysTransientSolution(XSeries(ansys), TakeSystem(sys, 5)) PlotResult([ansys, res5, res25], FileName = 'thrusterResult', Options = [{'color':(1,0,0)}, {'color':(0,1,0)}, {'color':(0,0,1)}]) PlotResult(Difference(ansys, [res5, res25]), FileName = 'thrusterDiff', Options = [{'color':(0,1,0)}, {'color':(0,0,1)}]) #Local Error Indicator er1 = LocalErrorIndicator(FrequencyConvergence(1, sys)) er10 = LocalErrorIndicator(FrequencyConvergence(10, sys)) er100 = LocalErrorIndicator(FrequencyConvergence(100, sys)) PlotConvergence([er1, er10, er100], FileName = 'thrusterErr', Options = [ {'marker':'o', 'markerfacecolor':(1,0,0), 'linewidth':0}, {'marker':'+', 'markerfacecolor':(0,1,0), 'linewidth':0}, {'marker':'d', 'markerfacecolor':(0,0,1), 'linewidth':0}], Legend = ('1 Hz', '10 Hz', '100 Hz'))