def test_minModelStep_stepExactFalse(): pList = [load_p('ladr_2d_p', modulepath)] nList = [load_n('ladr_2d_n', modulepath)] so = So() so.name = pList[0].name = "ladr" so.tnList = nList[0].tnList so.systemStepControllerType = SplitOperator.Sequential_MinModelStep so.systemStepExact = False so.sList = [default_s] opts.logLevel = 7 opts.verbose = True opts.profile = True opts.gatherArchive = True nList[0].runCFL = 0.33 nList[0].linearSolver = default_n.LU nList[0].multilevelLinearSolver = default_n.LU ns = NumericalSolution.NS_base(so, pList, nList, so.sList, opts) ns.calculateSolution('ladr_minModelStep_stepExactFalse') assert ns.tCount + 1 == len( so.tnList), "wrong number of archvie steps " + repr(ns.tCount) assert ns.modelList[0].solver.solverList[ 0].solveCalls == 34, "wrong number of steps " + repr( ns.modelList[0].solver.solverList[0].solveCalls) archiveTimes = [] for t in ns.ar[0].treeGlobal.iter('Time'): archiveTimes.append(t.attrib['Value']) archiveTimesCorrect = [ '0.0', '0.029516097303', '0.0516531702802', '0.0811692675832', '0.10330634056', '0.125443413538', '0.154959510841', '0.177096583818', '0.206612681121', '0.228749754098', '0.250886827075' ] npt.assert_almost_equal(np.array(archiveTimes, 'd'), np.array(archiveTimesCorrect, 'd')) del ns
def test_minModelStep_stepExactTrue(): pList = [load_p('ladr_2d_p', modulepath)] nList = [load_n('ladr_2d_n', modulepath)] so = So() so.name = pList[0].name = "ladr" so.tnList = nList[0].tnList so.systemStepControllerType = SplitOperator.Sequential_MinModelStep so.systemStepExact = True so.sList = [default_s] opts.logLevel = 7 opts.verbose = True opts.profile = True opts.gatherArchive = True nList[0].runCFL = 0.33 nList[0].linearSolver = default_n.LU nList[0].multilevelLinearSolver = default_n.LU ns = NumericalSolution.NS_base(so, pList, nList, so.sList, opts) ns.calculateSolution('ladr_minModelStep_stepExactTrue') assert ns.tCount + 1 == len( so.tnList), "wrong number of archvie steps " + repr(ns.tCount) assert ns.modelList[0].solver.solverList[ 0].solveCalls == 40, "wrong number of steps " + repr( ns.modelList[0].solver.solverList[0].solveCalls) archiveTimes = [] for t in ns.ar[0].treeGlobal.iter('Time'): archiveTimes.append(t.attrib['Value']) archiveTimesCorrect = so.tnList npt.assert_almost_equal(np.array(archiveTimes, 'd'), np.array(archiveTimesCorrect, 'd')) del ns
def test_minModelStep_stepExactTrue(): pList = [load_p('ladr_2d_p', modulepath)] nList = [load_n('ladr_2d_n', modulepath)] so = So() so.name = pList[0].name = "ladr" so.tnList = nList[0].tnList so.systemStepControllerType = SplitOperator.Sequential_MinModelStep so.systemStepExact=True so.sList=[default_s] opts.logLevel=7 opts.verbose=True opts.profile=True opts.gatherArchive=True nList[0].runCFL=0.33 nList[0].linearSolver=default_n.LU nList[0].multilevelLinearSolver=default_n.LU ns = NumericalSolution.NS_base(so,pList,nList,so.sList,opts) ns.calculateSolution('ladr_minModelStep_stepExactTrue') assert ns.tCount + 1 == len(so.tnList), "wrong number of archvie steps "+`ns.tCount` assert ns.modelList[0].solver.solverList[0].solveCalls == 40, "wrong number of steps "+`ns.modelList[0].solver.solverList[0].solveCalls` archiveTimes=[] for t in ns.ar[0].treeGlobal.iter('Time'): archiveTimes.append(t.attrib['Value']) archiveTimesCorrect = so.tnList npt.assert_almost_equal(np.array(archiveTimes,'d'), np.array(archiveTimesCorrect,'d')) del ns
def test_minModelStep_stepExactFalse(): pList = [load_p('ladr_2d_p', modulepath)] nList = [load_n('ladr_2d_n', modulepath)] so = So() so.name = pList[0].name = "ladr" so.tnList = nList[0].tnList so.systemStepControllerType = SplitOperator.Sequential_MinModelStep so.systemStepExact=False so.sList=[default_s] opts.logLevel=7 opts.verbose=True opts.profile=True opts.gatherArchive=True nList[0].runCFL=0.33 nList[0].linearSolver=default_n.LU nList[0].multilevelLinearSolver=default_n.LU ns = NumericalSolution.NS_base(so,pList,nList,so.sList,opts) ns.calculateSolution('ladr_minModelStep_stepExactFalse') assert ns.tCount + 1 == len(so.tnList), "wrong number of archvie steps " +`ns.tCount` assert ns.modelList[0].solver.solverList[0].solveCalls == 34, "wrong number of steps "+`ns.modelList[0].solver.solverList[0].solveCalls` archiveTimes=[] for t in ns.ar[0].treeGlobal.iter('Time'): archiveTimes.append(t.attrib['Value']) archiveTimesCorrect = ['0.0', '0.029516097303', '0.0516531702802', '0.0811692675832', '0.10330634056', '0.125443413538', '0.154959510841', '0.177096583818', '0.206612681121', '0.228749754098', '0.250886827075'] npt.assert_almost_equal(np.array(archiveTimes,'d'), np.array(archiveTimesCorrect,'d')) del ns
def test_run(self): from petsc4py import PETSc pList = [] nList = [] so = load_so('nonlinear_waves_so',modulepath) for (p,n) in so.pnList: pList.append(load_p(p,modulepath)) nList.append(load_n(n,modulepath)) if pList[-1].name == None: pList[-1].name = p so.name = "nonlinear_waves" if so.sList == []: for i in range(len(so.pnList)): s = default_s so.sList.append(s) Profiling.logLevel=7 Profiling.verbose=True # PETSc solver configuration OptDB = PETSc.Options() with open(petsc_options) as f: all = f.read().split() i=0 while i < len(all): if i < len(all)-1: if all[i+1][0]!='-': print "setting ", all[i].strip(), all[i+1] OptDB.setValue(all[i].strip('-'),all[i+1]) i=i+2 else: print "setting ", all[i].strip(), "True" OptDB.setValue(all[i].strip('-'),True) i=i+1 else: print "setting ", all[i].strip(), "True" OptDB.setValue(all[i].strip('-'),True) i=i+1 so.tnList=[0.0,0.001,0.011] #so.tnList=[0.0,0.001]+[0.001 + i*0.01 for i in range(1,int(round(0.03/0.01))+1)] ns = NumericalSolution.NS_base(so,pList,nList,so.sList,opts) ns.calculateSolution('nonlinear_waves') non_linear_log = NumericResults.create_log('proteus.log') text = non_linear_log.read() #if text.find('CFL') != -1: if text.find('Step Failed,') != -1: a = "No convergence" else: a = "good" if a == "No convergence": print ("Convergence issue") assert False else: assert True