Пример #1
0
import RiemannSolver
from RiemannSolver import *
from pylab import plot, figure, suptitle

rs = RiemannSolver(timeSteps=1, mwaves=2, mx=800, meqn=2, maux=2)

rs.q = random.random((rs.meqn, rs.mx))
rs.aux = random.random((rs.maux, rs.mx))
waves1, s1 = rs.solveVectorized(timer=True)
waves2, s2 = rs.solvePointwize(timer=True)


figure(1)
waveIndex = 0
componentIndex = 0

suptitle(
    "Figure 1: shows the curve of wave number {0}, for the component number {1}".format(
        waveIndex + 1, componentIndex + 2
    )
)
plot(waves1[componentIndex, waveIndex, :], "g")
Пример #2
0
from __future__ import absolute_import
import RiemannSolver
from RiemannSolver import *
from pylab import plot, figure, suptitle

rs = RiemannSolver(timeSteps=1, mwaves=2, mx=800, meqn=2, maux=2)

rs.q = random.random((rs.meqn, rs.mx))
rs.aux = random.random((rs.maux, rs.mx))
waves1, s1 = rs.solveVectorized(timer=True)
waves2, s2 = rs.solvePointwize(timer=True)

figure(1)
waveIndex = 0
componentIndex = 0

suptitle(
    "Figure 1: shows the curve of wave number {0}, for the component number {1}"
    .format(waveIndex + 1, componentIndex + 2))
plot(waves1[componentIndex, waveIndex, :], "g")
Пример #3
0
from __future__ import absolute_import
from __future__ import print_function
import RiemannSolver
from RiemannSolver import *
from numpy import load, absolute


tolerance = 0.00005
print("This script asserts the results for input read from data files q.npy and aux.npy with tolerance =", tolerance)



rs = RiemannSolver( 10, 2, 2**15, 2, 2)
    
rs.q = load("q.npy")
rs.aux = load("aux.npy")

wavesRead = load("waves.npy")
sRead = load("s.npy")

waves1, s1  = rs.solveVectorized(timer = True)
#waves2, s2  = rs.solvePointwize(timer = True)

assert (absolute(wavesRead - waves1)< tolerance).all()
assert (absolute(sRead -s1)< tolerance).all()

Пример #4
0
from pylab import plot, figure, suptitle
from six.moves import range

print("Testing for different number of time steps ...")
noOfTestSamples = 10
max_mx = 101
max_timeSteps = 101

timesStepsValues = empty((noOfTestSamples))
timeResultsVectorized = empty((noOfTestSamples))
timeResultsPointwise = empty((noOfTestSamples))
# error when max_mx is devisible by noOfTestSamples. size of arrays should be noOfTestSamples-1, use j to decide what to plot

rs = RiemannSolver(timeSteps=max_timeSteps / noOfTestSamples,
                   mwaves=2,
                   mx=max_mx,
                   meqn=2,
                   maux=2)

rs.q = random.random((rs.meqn, rs.mx))
rs.aux = random.random((rs.maux, rs.mx))

j = 0
for i in range(max_timeSteps / noOfTestSamples, max_timeSteps,
               max_timeSteps / noOfTestSamples):
    timesStepsValues[j] = i
    rs.timeSteps = i
    print()
    print("Iteration", j + 1, "of", noOfTestSamples)
    print("Number of time steps is", i)
Пример #5
0
from __future__ import absolute_import
from __future__ import print_function
import RiemannSolver
from RiemannSolver import *
from numpy import load, absolute

tolerance = 0.00005
print(
    "This script asserts the results for input read from data files q.npy and aux.npy with tolerance =",
    tolerance)

rs = RiemannSolver(10, 2, 2**15, 2, 2)

rs.q = load("q.npy")
rs.aux = load("aux.npy")

wavesRead = load("waves.npy")
sRead = load("s.npy")

waves1, s1 = rs.solveVectorized(timer=True)
#waves2, s2  = rs.solvePointwize(timer = True)

assert (absolute(wavesRead - waves1) < tolerance).all()
assert (absolute(sRead - s1) < tolerance).all()