Ejemplo n.º 1
0
meshSz = [[], []]
poly = [[], []]
meshSz[0] = [5 * 2**i for i in range(5)]
meshSz[1] = [5 * 2**i for i in range(3, 4)]
#meshSz[1] = [5*2**i for i in range(4)]
poly[0] = range(1, 4)
poly[1] = range(2, 3)
#poly[1] = range(1,3)
for probNum in range(len(femsol)):
    for meshNum in range(len(meshSz[probNum])):
        femsol[probNum].append([])
        for polyNum in range(len(poly[probNum])):
            namestr = "prob%d_%d_%d.setup" % (
                probNum + 1, meshSz[probNum][meshNum], poly[probNum][polyNum])
            print "Problem " + namestr + " ..."
            femsol[probNum][meshNum].append(FEM.FEMcalc("setups/" + namestr))
            print " solved"

print "calculating l2 errors"
#go through and calculate l2 errors and convergence rates
exsol = [None, None]
exsol[0] = lambda x: math.sin(x[0]) - math.sin(1) * x[0]
exsol[1] = lambda x, y: femsol[1][-1][-1]  #use best solution as exact solution
l2err = [[], []]
conRate = [[], []]
for probNum in range(len(femsol)):
    for meshNum in range(len(meshSz[probNum])):
        l2err[probNum].append([])
        conRate[probNum].append([])
        for polyNum in range(len(poly[probNum])):
            l2err[probNum][meshNum].append(
Ejemplo n.º 2
0
#generates all the plots for problem 2
import FEM

print "calculating fin401A"
FEM.FEMcalc("setups/fin401A.setup",True)
print "calculating fin401B"
FEM.FEMcalc("setups/fin401B.setup",True)
print "calculating fin801A"
FEM.FEMcalc("setups/fin801A.setup",True)
print "calculating fin801B"
FEM.FEMcalc("setups/fin801B.setup",True)
print "calculating fin801A2"
FEM.FEMcalc("setups/fin801A2.setup",True)
print "calculating fin801B2"
FEM.FEMcalc("setups/fin801B2.setup",True)

#generates all the plots for problem 2
import FVM

print "calculating fin2A1"
FVM.FVMcalc("setups/fin2A1.setup",True)
print "calculating fin2A2"
FVM.FVMcalc("setups/fin2A2.setup",True)
print "calculating fin2B1"
FVM.FVMcalc("setups/fin2B1.setup",True)
print "calculating fin2B2"
FVM.FVMcalc("setups/fin2B2.setup",True)
print "calculating fin21"
FVM.FVMcalc("setups/fin21.setup",True)
print "calculating fin22"
FVM.FVMcalc("setups/fin22.setup",True)