Skip to content
Snippets Groups Projects
Commit 747cab94 authored by Nicolas Marsic's avatar Nicolas Marsic
Browse files

getdp: executable script + new folder structure

parent df929b41
No related branches found
No related tags found
No related merge requests found
Makefile 0 → 100644
test: initcavity runcavity
initcavity:
cd cavity && gmsh square.geo -2
runcavity:
python src/cim.py cavity/maxwell.pro cavity/square.msh Maxwell Maxwell 9e8 1e8
clean:
rm -f src/*.pyc
rm -f cavity/*.pos
rm -f cavity/*.pre
rm -f cavity/*.msh
File moved
File moved
File moved
import argparse
def parse():
"""Parses the python script arguments
Returns an argparse
"""
# Initialise
parser = argparse.ArgumentParser()
# Position argumets
parser.add_argument("pro", type=str,
help="GetDP .pro file")
parser.add_argument("mesh", type=str,
help="Gmsh .msh file")
parser.add_argument("resolution", type=str,
help="resolution from .pro file")
parser.add_argument("post", type=str,
help="post-operation from .pro file")
parser.add_argument("origin", type=complex,
help="circular contour origin (complex)")
parser.add_argument("radius", type=float,
help="circular contour radius")
# Optional arguments
parser.add_argument("-nodes", type=int, default=100,
help="number of nodes for trapezoidal rule")
parser.add_argument("-maxIt", type=int, default=10,
help="maximam number of iterations")
parser.add_argument("-lStart", type=int, default=1,
help="initial size of col(A0)")
parser.add_argument("-lStep", type=int, default=1,
help="step size for increasing col(A0)")
parser.add_argument("-rankTol", type=float, default=1e-4,
help="tolerance for rank test")
parser.add_argument("-quiet", action='store_true',
help="should I be quiet?")
# Done
return parser.parse_args()
......@@ -175,7 +175,7 @@ def display(nodes, maxIt, lStart, lStep, rankTol, origin, radius):
print " # Nodes used for the trapezoidal rule:" + " " + str(nodes)
print " # Maximum number of iterations: " + " " + str(maxIt)
print " # Initial size of col(A0): " + " " + str(lStart)
print " # Step size for col(A0): " + " " + str(lStep)
print " # Step size for increasing col(A0): " + " " + str(lStep)
print " # Rank test tolerance: ",
print format(rankTol, '.2e')
print "---------------------------------------"
......
#!/usr/bin/env python2
import solver as Solver
import beyn as Beyn
import numpy as np
import args as args
# Data
pro = "maxwell.pro"
mesh = "square.msh"
resolution = "Maxwell"
post = "Maxwell"
# Parse arguments
arg = args.parse()
# Initialise GetDP
operator = Solver.GetDPWave(pro, mesh, resolution)
operator = Solver.GetDPWave(arg.pro, arg.mesh, arg.resolution)
# Compute
l, V = Beyn.simple(operator, complex(9e8, 0), 1e8)
l, V = Beyn.simple(operator, arg.origin, arg.radius,
arg.nodes, arg.maxIt, arg.lStart, arg.lStep, arg.rankTol,
not arg.quiet)
# Display the computed eigenvalues
print
print "Eigenvalues:"
print "----------- "
if(not arg.quiet):
print
print "Eigenvalues:"
print "----------- "
for i in range(l.shape[0]):
print " # " + str(i) + ": ",
if(not arg.quiet): print " # " + str(i) + ": ",
print "(" + format(np.real(l[i]).tolist(), '+e') + ")",
print "+",
print "(" + format(np.imag(l[i]).tolist(), '+e') + ")*j"
print "----------- "
print "Found: " + str(l.shape[0])
if(not arg.quiet):
print "----------- "
print "Found: " + str(l.shape[0])
# Generate GetDP views for eigenvectors
print
print "Generating eigenvector views..."
if(not arg.quiet):
print
print "Generating eigenvector views..."
for i in range(l.shape[0]):
operator.view(V[:, i], post, "beyn" + str(i) + ".pos")
print " # View: " + str(i) + " done!"
operator.view(V[:, i], arg.post, "beyn" + str(i) + ".pos")
if(not arg.quiet): print " # View: " + str(i) + " done!"
# Done
print
print "return 0;"
if(not arg.quiet):
print
print "Bye!"
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment