Пример #1
0

Nq = 16
Np = 3
dirs = cubeRotations(cubeDirections(Np))
quad=trianglequadrature(Nq)


elttobasis = [[PlaneWaves(dirs, k)]] * mesh.nelements

params={'alpha':.5, 'beta':.5,'delta':.5}

l_coeffs=[-1j*k, 1]
r_coeffs=[-1j*k, 1]
      
bnddata={82:zero_impedance(k), 83:dirichlet(g) }

mqs = MeshQuadratures(mesh, quad)
lv = LocalVandermondes(mesh, elttobasis, mqs, usecache=False)
bndvs=[]
for data in bnddata.values():
    bndv = LocalVandermondes(mesh, [[data]] * mesh.nelements, mqs)        
    bndvs.append(bndv)


S, f = assemble(mesh, k, lv, bndvs, mqs, elttobasis, bnddata, params)


print "Solving system"

Пример #2
0
    #return 1+.5*1./4*(p[:,0]-1)
    return np.exp(1./5*p[:,0]*(5-p[:,0]))
    
import pypwdg.parallel.main

k = 10
direction=array([[1.0,0]])
g = pcb.PlaneWaves(direction, k)




bnddata={7:pcbd.dirichlet(g),
         8:pcbd.generic_boundary_data([-1j*k,1],[-1j*k,1],g=g)}

bnddata={7:pcbd.dirichlet(g), 8:pcbd.zero_impedance(k)}

bounds=array([[0.001,4.999],[0,1]],dtype='d')
npoints=array([500,100])

mesh = pmm.gmshMesh('waveguide.msh',dim=2)


quadpoints = 30
p=3
t=p**2
g=2
h=.1

beta=p**2*h*k
alpha=k*p**2*1./h
Пример #3
0
        return self.a - r2 * (self.a - 1.0) / self.R ** 2


def expBubble(x):

    return np.exp(-(1 - x ** 2))


entityton = {1: expBubble}

import pypwdg.parallel.main

from numpy import array, sqrt


k = 50
direction = array([[1.0]])
g = pcb.PlaneWaves(direction, k)

bnddata = {10: pcbd.dirichlet(g), 11: pcbd.zero_impedance(k)}

bounds = array([[-1, 1]], dtype="d")
npoints = array([200])

mesh = pmm.lineMesh(points=[-1, 1], nelems=[1000], physIds=[1])
problem = psp.VariableNProblem(entityton, mesh, k, bnddata)
# computation = psc.Computation(problem, pcb.planeWaveBases(1,k), pcp.HelmholtzSystem, 15)
computation = psc.Computation(problem, pcbr.ReferenceBasisRule(pcbr.Legendre1D(2)), pcp.HelmholtzSystem, 15)
solution = computation.solution(psc.DirectSolver().solve, dovolumes=True)
pos.standardoutput(computation, solution, 20, bounds, npoints, "soundsoft")
Пример #4
0
import pypwdg.setup as ps
import pypwdg.core.bases as pcb
import pypwdg.mesh.mesh as pmm
import pypwdg.core.boundary_data as pcbd
import pypwdg.parallel.main

from numpy import array
import math

k = 10

g = pcb.PlaneWaves(array([[1,0,0]])/math.sqrt(1), k)

bnddata={82:pcbd.zero_impedance(k), 83:pcbd.dirichlet(g) }

bounds=array([[-2,2],[-2,2],[-2,2]],dtype='d')
npoints=array([200,200,200])

mesh = pmm.gmshMesh('scattmesh.msh',dim=3)
bases = pcb.planeWaveBases(mesh, k, 3)

problem=ps.Problem(mesh,k,16, bnddata)
solution = ps.Computation(problem, bases).solve()
solution.writeSolution(bounds,npoints,fname='scattmesh.vti')
problem.writeMesh(fname='scattmesh.vtu',scalars=solution.combinedError())

Пример #5
0
#mesh.partition(4)
#print cubemesh.nodes
    

boundaryentities = [10,11]
#SM = StructureMatrices(mesh, boundaryentities)

Nq = 20
Np = 15
dirs = circleDirections(Np)
elttobasis = [[PlaneWaves(dirs, k)]] * mesh.nelements

params={'alpha':.5, 'beta':.5,'delta':.5}
      
bnddata={11:dirichlet(g), 
         10:zero_impedance(k)}


quad=legendrequadrature(Nq)
mqs = MeshQuadratures(mesh, quad)
lv = LocalVandermondes(mesh, elttobasis, mqs, usecache=True)
bndvs=[]
for data in bnddata.values():
    bndv = LocalVandermondes(mesh, [[data]] * mesh.nelements, mqs)        
    bndvs.append(bndv)


quad=legendrequadrature(Nq)
S, f = assemble(mesh, k, lv, bndvs, mqs, elttobasis, bnddata, params)

print "Solving system"
Пример #6
0
omega = effectivek * veldata.averagevel / (ymax - ymin)
averagek = effectivek / (ymax - ymin)
trueh = effectiveh / (ymax - ymin)
print "omega = %s" % omega
print "bounds %s" % veldata.bounds
print veldata.averagevel
npoints = np.array([veldata.nx, veldata.ny])
# pom.output2dfn(veldata.bounds, veldata, npoints)


sourcexpos = (xmax + xmin) / 2
sourcek = veldata(np.array([[sourcexpos, 0]]))[0] * averagek
g = pcb.FourierHankel([sourcexpos, 0], [0], sourcek)

sourceimp = pcbd.generic_boundary_data([-1j * averagek, 1], [-1j * averagek, 1], g)
zeroimp = pcbd.zero_impedance(averagek)

entityton = {5: veldata}
mesh = ptum.regularrectmesh(
    [xmin, xmax], [ymin, ymax], int(((xmax - xmin) / (ymax - ymin)) / effectiveh), int(1 / effectiveh)
)
print mesh.nelements
bnddata = {1: zeroimp, 2: sourceimp, 3: zeroimp, 4: zeroimp}
# bdndata = {0:impbd, 1:pcbd.zero_impedance}

problem = psp.VariableNProblem(entityton, mesh, averagek, bnddata)

alpha = ((pdeg * 1.0) ** 2 / trueh) / averagek
beta = averagek / (pdeg * 1.0 * trueh)

pw = pcbv.PlaneWaveVariableN(pcb.circleDirections(npw))
Пример #7
0
import pypwdg.raytrace.wavefront as prw
import pypwdg.raytrace.basisrules as prb
import pypwdg.output.mploutput as pom
import pypwdg.parallel.main
import pypwdg.test.utils.mesh as ptum
import pypwdg.core.bases.reduced as pcbred
import pypwdg.utils.quadrature as puq
import pypwdg.raytrace.wavefront as prw
import numpy as np

k = 20
direction=np.array([[0.0,1.0]])
g = pcb.PlaneWaves(direction, k)
#g = pcb.FourierHankel([-2,-2], [0], k)
impbd = pcbd.generic_boundary_data([-1j*k,1],[-1j*k,1],g)
zerobd = pcbd.zero_impedance(k)

#bnddata={7:impbd, 
#         8:impbd}
#bnddata={7:pcbd.dirichlet(g), 
#         8:pcbd.dirichlet(g)}

bounds=np.array([[0,1],[0,1]],dtype='d')
npoints=np.array([500,500])

npw = 15
quadpoints = 8
pdeg = 2

c = 1
N = 20