In [1]:
from HelmholtzSolverRAD import *
from ExampleBoundaries import SphereRAD

frequency = 40.0 # frequency [Hz]
k = frequencyToWavenumber(frequency)

interiorPoints = np.array([[0.0000,  0.0000],
                           [0.0000,  0.5000],
                           [0.0000, -0.5000],
                           [0.5000,  0.0000]], dtype=np.float32)


# Test Problem 1
# Dirichlet boundary condition with phi = sin(k*z)
#
solver = HelmholtzSolverRAD(*(SphereRAD()))

boundaryCondition = BoundaryCondition(solver.aElement.shape[0])
boundaryCondition.alpha.fill(1.0)
boundaryCondition.beta.fill(0.0)
boundaryCondition.f[:] = np.sin(k * solver.aCenters[:,1])

boundaryIncidence = BoundaryIncidence(solver.aElement.shape[0])
boundaryIncidence.phi.fill(0.0)
boundaryIncidence.v.fill(0.0)

interiorIncidentPhi = np.zeros(interiorPoints.shape[0], dtype=np.complex64)

boundarySolution = solver.solveInteriorBoundary(k, boundaryCondition, boundaryIncidence)
interiorPhi = solver.solveInterior(boundarySolution, interiorIncidentPhi, interiorPoints)

print "Test Problem 1"
print "==============\n"
print boundarySolution
printInteriorSolution(boundarySolution, interiorPhi)


# Test Problem 2
# von Neumann boundary condition such that phi = sin(k/sqrt(2) * x) * sin(k/sqrt(2) * y)
# Differentiate with respect to x and y to obtain outward normal
boundaryCondition.alpha.fill(0.0)
boundaryCondition.beta.fill(1.0)
for i in range(solver.aCenters.shape[0]):
    z = solver.aCenters[i, 1]
    n = Normal2D(solver.aVertex[solver.aElement[i,0],:], 
                 solver.aVertex[solver.aElement[i,1],:])
    boundaryCondition.f[i] = k * np.cos(k*z) * n[1]
    
boundarySolution = solver.solveInteriorBoundary(k, boundaryCondition, boundaryIncidence)
interiorPhi = solver.solveSamples(boundarySolution, interiorIncidentPhi, interiorPoints, 'interior')

print "\n\nTest Problem 2"
print "==============\n"
print boundarySolution
printInteriorSolution(boundarySolution, interiorPhi)


# Test Problem 3
# Dirichlet boundary condition, such that phi = sin(k/ sqrt(2) * x) * sin(k/sqrt(2) * y)
# Differentiate with respect to x and y to obtain outward normal
boundaryCondition.alpha.fill(1.0)
boundaryCondition.beta.fill(0.0)

zp = 0.25
for i in range(solver.aCenters.shape[0]):
    r = solver.aCenters[i, 0]
    z = solver.aCenters[i, 1]
    # make input complex so proper sqrt is called
    rpq = np.sqrt(0.0j + r**2 + (z - zp)**2)
    boundaryCondition.f[i]   = np.exp(1j * k * rpq) / (4.0 * np.pi * rpq)
    boundaryIncidence.phi[i] = np.exp(1j * k * rpq) / (4.0 * np.pi * rpq)
    n = Normal2D(solver.aVertex[solver.aElement[i,0],:], 
                 solver.aVertex[solver.aElement[i,1],:])
    drbdn = (r * n[0] + (z - zp) * n[1]) / rpq
    boundaryIncidence.v[i] = drbdn * np.exp(1j * k * rpq) * (1j * k * rpq - 1.0) \
        / (4.0 * np.pi * rpq*rpq)
    
for i in range(interiorPoints.shape[0]):
    r = interiorPoints[i, 0]
    z = interiorPoints[i, 1]
    # make input complex so proper sqrt is called
    rpq = np.sqrt(0.0j + r**2 + (zp - z)**2)
    interiorIncidentPhi[i] = np.exp(1j * k * rpq) / (4.0 * np.pi * rpq)
       
boundarySolution = solver.solveInteriorBoundary(k, boundaryCondition, boundaryIncidence)
interiorPhi = solver.solveInterior(boundarySolution, interiorIncidentPhi, interiorPoints)

print "\n\nTest Problem 3"
print "==============\n"
print boundarySolution
printInteriorSolution(boundarySolution, interiorPhi)


Test Problem 1
==============

Density of medium:      1.205 kg/m^3
Speed of sound:         344.0 m/s
Wavenumber (Frequency): 0.730602942695 (40.0 Hz)

index          Potential                   Pressure                    Velocity              Intensity
    1   6.6323e-01+  0.0000e+00i    0.0000e+00+  2.0086e+02i    5.4833e-01+ -2.3443e-03i    -2.3543e-01
    2   6.4667e-01+  0.0000e+00i    0.0000e+00+  1.9584e+02i    5.4436e-01+ -2.6372e-03i    -2.5824e-01
    3   6.1291e-01+  0.0000e+00i    0.0000e+00+  1.8562e+02i    5.2844e-01+ -2.4182e-03i    -2.2443e-01
    4   5.6148e-01+  0.0000e+00i    0.0000e+00+  1.7004e+02i    5.0052e-01+ -2.0080e-03i    -1.7072e-01
    5   4.9228e-01+  0.0000e+00i    0.0000e+00+  1.4909e+02i    4.5458e-01+ -1.6385e-03i    -1.2214e-01
    6   4.0551e-01+  0.0000e+00i    0.0000e+00+  1.2281e+02i    3.8677e-01+ -1.2074e-03i    -7.4140e-02
    7   3.0276e-01+  0.0000e+00i    0.0000e+00+  9.1690e+01i    2.9804e-01+ -7.1712e-04i    -3.2876e-02
    8   1.8738e-01+  0.0000e+00i    0.0000e+00+  5.6748e+01i    1.8773e-01+ -4.6962e-04i    -1.3325e-02
    9   6.3520e-02+  0.0000e+00i    0.0000e+00+  1.9237e+01i    6.3589e-02+ -2.1461e-04i    -2.0642e-03
   10  -6.3520e-02+  0.0000e+00i   -0.0000e+00+ -1.9237e+01i   -6.3589e-02+  2.1463e-04i    -2.0644e-03
   11  -1.8738e-01+  0.0000e+00i   -0.0000e+00+ -5.6748e+01i   -1.8773e-01+  4.6965e-04i    -1.3326e-02
   12  -3.0276e-01+  0.0000e+00i   -0.0000e+00+ -9.1690e+01i   -2.9804e-01+  7.1710e-04i    -3.2875e-02
   13  -4.0551e-01+  0.0000e+00i   -0.0000e+00+ -1.2281e+02i   -3.8677e-01+  1.2073e-03i    -7.4135e-02
   14  -4.9228e-01+  0.0000e+00i   -0.0000e+00+ -1.4909e+02i   -4.5458e-01+  1.6384e-03i    -1.2214e-01
   15  -5.6148e-01+  0.0000e+00i   -0.0000e+00+ -1.7004e+02i   -5.0052e-01+  2.0079e-03i    -1.7072e-01
   16  -6.1291e-01+  0.0000e+00i   -0.0000e+00+ -1.8562e+02i   -5.2844e-01+  2.4180e-03i    -2.2442e-01
   17  -6.4667e-01+  0.0000e+00i   -0.0000e+00+ -1.9584e+02i   -5.4436e-01+  2.6371e-03i    -2.5823e-01
   18  -6.6323e-01+  0.0000e+00i   -0.0000e+00+ -2.0086e+02i   -5.4833e-01+  2.3441e-03i    -2.3542e-01


Sound pressure at the sample points

index          Potential                    Pressure               Magnitude         Phase

    1   1.3007e-08+ -1.4219e-08i    4.3063e-06+  3.9392e-06i    -1.0698e+01 dB       0.7409
    2   3.5732e-01+ -3.9584e-04i    1.1988e-01+  1.0821e+02i     1.3467e+02 dB       1.5697
    3  -3.5732e-01+  3.9579e-04i   -1.1987e-01+ -1.0821e+02i     1.3467e+02 dB       -1.5719
    4   9.4524e-09+ -1.6619e-08i    5.0332e-06+  2.8627e-06i    -1.0767e+01 dB       0.5171


Test Problem 2
==============

Density of medium:      1.205 kg/m^3
Speed of sound:         344.0 m/s
Wavenumber (Frequency): 0.730602942695 (40.0 Hz)

index          Potential                   Pressure                    Velocity              Intensity
    1   6.5667e-01+  2.6385e-03i   -7.9908e-01+  1.9887e+02i    5.4478e-01+  0.0000e+00i    -2.1766e-01
    2   6.3999e-01+  2.6008e-03i   -7.8764e-01+  1.9382e+02i    5.3831e-01+  0.0000e+00i    -2.1200e-01
    3   6.0656e-01+  2.4207e-03i   -7.3312e-01+  1.8370e+02i    5.2279e-01+  0.0000e+00i    -1.9163e-01
    4   5.5568e-01+  2.1424e-03i   -6.4882e-01+  1.6829e+02i    4.9544e-01+  0.0000e+00i    -1.6073e-01
    5   4.8717e-01+  1.8108e-03i   -5.4841e-01+  1.4754e+02i    4.4968e-01+  0.0000e+00i    -1.2331e-01
    6   4.0132e-01+  1.4290e-03i   -4.3277e-01+  1.2154e+02i    3.8272e-01+  0.0000e+00i    -8.2815e-02
    7   2.9967e-01+  1.0156e-03i   -3.0756e-01+  9.0756e+01i    2.9533e-01+  0.0000e+00i    -4.5417e-02
    8   1.8544e-01+  6.1957e-04i   -1.8764e-01+  5.6159e+01i    1.8569e-01+  0.0000e+00i    -1.7421e-02
    9   6.2831e-02+  2.1466e-04i   -6.5011e-02+  1.9028e+01i    6.2624e-02+  0.0000e+00i    -2.0356e-03
   10  -6.2831e-02+ -2.1494e-04i    6.5095e-02+ -1.9028e+01i   -6.2624e-02+  0.0000e+00i    -2.0382e-03
   11  -1.8544e-01+ -6.1985e-04i    1.8772e-01+ -5.6159e+01i   -1.8569e-01+  0.0000e+00i    -1.7428e-02
   12  -2.9967e-01+ -1.0158e-03i    3.0764e-01+ -9.0756e+01i   -2.9533e-01+  0.0000e+00i    -4.5429e-02
   13  -4.0132e-01+ -1.4292e-03i    4.3284e-01+ -1.2154e+02i   -3.8272e-01+  0.0000e+00i    -8.2829e-02
   14  -4.8717e-01+ -1.8111e-03i    5.4848e-01+ -1.4754e+02i   -4.4968e-01+  0.0000e+00i    -1.2332e-01
   15  -5.5568e-01+ -2.1426e-03i    6.4889e-01+ -1.6829e+02i   -4.9544e-01+  0.0000e+00i    -1.6074e-01
   16  -6.0656e-01+ -2.4210e-03i    7.3318e-01+ -1.8370e+02i   -5.2279e-01+  0.0000e+00i    -1.9165e-01
   17  -6.3999e-01+ -2.6009e-03i    7.8770e-01+ -1.9382e+02i   -5.3831e-01+  0.0000e+00i    -2.1201e-01
   18  -6.5667e-01+ -2.6387e-03i    7.9914e-01+ -1.9887e+02i   -5.4478e-01+  0.0000e+00i    -2.1767e-01


Sound pressure at the sample points

index          Potential                    Pressure               Magnitude         Phase

    1   3.5216e-08+ -1.4871e-07i    4.5038e-05+  1.0665e-05i     7.2879e+00 dB       0.2325
    2   3.5364e-01+  9.7470e-04i   -2.9519e-01+  1.0710e+02i     1.3458e+02 dB       1.5736
    3  -3.5364e-01+ -9.7499e-04i    2.9527e-01+ -1.0710e+02i     1.3458e+02 dB       -1.5680
    4   3.7430e-08+ -1.5193e-07i    4.6013e-05+  1.1336e-05i     7.4930e+00 dB       0.2415


Test Problem 3
==============

Density of medium:      1.205 kg/m^3
Speed of sound:         344.0 m/s
Wavenumber (Frequency): 0.730602942695 (40.0 Hz)

index          Potential                   Pressure                    Velocity              Intensity
    1   9.0960e-02+  5.5292e-02i   -1.6745e+01+  2.7547e+01i   -1.6352e-01+ -4.3162e-03i     1.3096e+00
    2   8.9328e-02+  5.5215e-02i   -1.6722e+01+  2.7053e+01i   -1.5902e-01+ -4.4929e-03i     1.2687e+00
    3   8.6360e-02+  5.5067e-02i   -1.6677e+01+  2.6154e+01i   -1.5109e-01+ -4.8192e-03i     1.1968e+00
    4   8.2338e-02+  5.4851e-02i   -1.6611e+01+  2.4936e+01i   -1.4093e-01+ -5.2475e-03i     1.1051e+00
    5   7.7661e-02+  5.4572e-02i   -1.6527e+01+  2.3520e+01i   -1.3003e-01+ -5.7669e-03i     1.0067e+00
    6   7.2735e-02+  5.4242e-02i   -1.6427e+01+  2.2028e+01i   -1.1943e-01+ -6.3294e-03i     9.1119e-01
    7   6.7790e-02+  5.3868e-02i   -1.6314e+01+  2.0530e+01i   -1.0964e-01+ -6.8973e-03i     8.2355e-01
    8   6.3061e-02+  5.3465e-02i   -1.6192e+01+  1.9098e+01i   -1.0118e-01+ -7.4845e-03i     7.4765e-01
    9   5.8701e-02+  5.3047e-02i   -1.6065e+01+  1.7778e+01i   -9.3932e-02+ -8.0498e-03i     6.8296e-01
   10   5.4727e-02+  5.2621e-02i   -1.5936e+01+  1.6574e+01i   -8.7786e-02+ -8.5755e-03i     6.2843e-01
   11   5.1197e-02+  5.2204e-02i   -1.5810e+01+  1.5505e+01i   -8.2794e-02+ -9.0821e-03i     5.8408e-01
   12   4.8157e-02+  5.1811e-02i   -1.5691e+01+  1.4584e+01i   -7.8720e-02+ -9.5411e-03i     5.4801e-01
   13   4.5566e-02+  5.1449e-02i   -1.5581e+01+  1.3800e+01i   -7.5390e-02+ -9.9400e-03i     5.1875e-01
   14   4.3421e-02+  5.1129e-02i   -1.5484e+01+  1.3150e+01i   -7.2812e-02+ -1.0291e-02i     4.9606e-01
   15   4.1732e-02+  5.0863e-02i   -1.5404e+01+  1.2639e+01i   -7.0828e-02+ -1.0577e-02i     4.7867e-01
   16   4.0463e-02+  5.0654e-02i   -1.5341e+01+  1.2254e+01i   -6.9368e-02+ -1.0794e-02i     4.6593e-01
   17   3.9617e-02+  5.0511e-02i   -1.5297e+01+  1.1998e+01i   -6.8459e-02+ -1.0952e-02i     4.5792e-01
   18   3.9212e-02+  5.0441e-02i   -1.5276e+01+  1.1875e+01i   -6.7892e-02+ -1.1027e-02i     4.5309e-01


Sound pressure at the sample points

index          Potential                    Pressure               Magnitude         Phase

    1   3.1185e-01+  5.8800e-02i   -1.7807e+01+  9.4443e+01i     1.3363e+02 dB       1.7572
    2   3.1163e-01+  5.8990e-02i   -1.7865e+01+  9.4376e+01i     1.3363e+02 dB       1.7579
    3   8.9605e-02+  5.6063e-02i   -1.6979e+01+  2.7137e+01i     1.2409e+02 dB       2.1299
    4   1.2952e-01+  5.7488e-02i   -1.7410e+01+  3.9225e+01i     1.2663e+02 dB       1.9885

Copyright (C) 2017 Frank Jargstorff

This file is part of the AcousticBEM library.

AcousticBEM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

AcousticBEM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with AcousticBEM. If not, see http://www.gnu.org/licenses/.