本文整理汇总了Python中sailfish.controller.LBSimulationController类的典型用法代码示例。如果您正苦于以下问题:Python LBSimulationController类的具体用法?Python LBSimulationController怎么用?Python LBSimulationController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LBSimulationController类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_timeseries
def test_timeseries(self):
settings = {
'debug_single_process': True,
'quiet': True,
'lat_nx': 64,
'lat_ny': 32,
'max_iters': 1,
'check_invalid_results_host': False,
'check_invalid_results_gpu': False,
'every': 1,
}
x1 = np.arange(0, 20 * 8, 8)
x2 = np.arange(0, 60 * 1.61, 1.61)
x3 = np.arange(0, 20 * 4, 4)
# This one test time-wrapping and a non-integer step size.
cc = np.hstack([cos_timeseries, cos_timeseries, cos_timeseries])
f1 = interp1d(x1, sin_timeseries, kind='linear')
f2 = interp1d(x2, cc, kind='linear')
f3 = interp1d(x3, 2.0 * sin_timeseries, kind='linear')
ctrl = LBSimulationController(TestSim, default_config=settings)
ctrl.run(ignore_cmdline=True)
runner = ctrl.master.runner
sim = ctrl.master.sim
while sim.iteration < 60:
runner.step(True)
runner._fields_to_host(True)
self.assertAlmostEqual(sim.rho[0,5], f1(sim.iteration - 1), places=6)
self.assertAlmostEqual(sim.rho[0,6], f2(sim.iteration - 1), places=6)
self.assertAlmostEqual(sim.rho[0,7], f3(sim.iteration - 1), places=6)
开发者ID:PokerN,项目名称:sailfish,代码行数:34,代码来源:time_series.py
示例2: run_test
def run_test(name):
basepath = os.path.join("results", name)
if not os.path.exists(basepath):
os.makedirs(basepath)
ctrl = LBSimulationController(TestLDCSim, TestLDCGeometry)
ctrl.run()
horiz = np.loadtxt("ldc_golden/re400_horiz", skiprows=1)
vert = np.loadtxt("ldc_golden/re400_vert", skiprows=1)
plt.plot(2 * (horiz[:, 0] - 0.5), -2 * (horiz[:, 1] - 0.5), label="Sheu, Tsai paper")
plt.plot(2 * (vert[:, 0] - 0.5), -2 * (vert[:, 1] - 0.5), label="Sheu, Tsai paper")
save_output(basepath)
plt.legend(loc="lower right")
plt.gca().yaxis.grid(True)
plt.gca().xaxis.grid(True)
plt.gca().xaxis.grid(True, which="minor")
plt.gca().yaxis.grid(True, which="minor")
plt.title("Lid Driven Cavity, Re = 400")
print os.path.join(basepath, "re400.pdf")
plt.savefig(os.path.join(basepath, "re400.pdf"), format="pdf")
plt.clf()
plt.cla()
plt.show()
shutil.rmtree(tmpdir)
开发者ID:shawakaze,项目名称:sailfish,代码行数:27,代码来源:ldc_3d.py
示例3: run_test
def run_test(name, re, max_iters, i):
print 'Testing Re = %s' % re
basepath = os.path.join('results', name, 're%s' % re)
if not os.path.exists(basepath):
os.makedirs(basepath)
ctrl = LBSimulationController(TestLDCSim,
default_config={'re': re, 'max_iters': max_iters})
ctrl.run(ignore_cmdline=True)
horiz = np.loadtxt('ldc_golden/vx2d', skiprows=4)
vert = np.loadtxt('ldc_golden/vy2d', skiprows=4)
plt.plot(horiz[:, 0] * 2 - 1, horiz[:, i], '.', label='Paper')
plt.plot(vert[:, i], 2 * (vert[:, 0] - 0.5), '.', label='Paper')
save_output(basepath, max_iters)
plt.legend(loc='lower right')
plt.gca().yaxis.grid(True)
plt.gca().xaxis.grid(True)
plt.gca().xaxis.grid(True, which='minor')
plt.gca().yaxis.grid(True, which='minor')
plt.title('2D Lid Driven Cavity, Re = %s' % re)
print os.path.join(basepath, 'results.pdf')
plt.savefig(os.path.join(basepath, 'results.pdf'), format='pdf')
plt.clf()
plt.cla()
plt.show()
开发者ID:PokerN,项目名称:sailfish,代码行数:29,代码来源:ldc_2d.py
示例4: test_x_face_propagation
def test_x_face_propagation(self):
global tmpdir
ctrl = LBSimulationController(SingleBlockPeriodicSimulationTest,
SingleBlockGeoTest)
ctrl.run(ignore_cmdline=True)
output = os.path.join(tmpdir, 'per_single_out')
b0 = np.load(io.dists_filename(output, 1, 0, 1))
ae = np.testing.assert_equal
ae(b0[vi(-1, 0, 0), 32, 32, 64], np.float32(0.11))
ae(b0[vi(-1, 1, 0), 32, 33, 64], np.float32(0.12))
ae(b0[vi(-1, -1, 0), 32, 31, 64], np.float32(0.13))
ae(b0[vi(-1, 0, 1), 33, 32, 64], np.float32(0.14))
ae(b0[vi(-1, 0, -1), 31, 32, 64], np.float32(0.15))
ae(b0[vi(0, 1, 0), 33, 1, 31], np.float32(0.41))
ae(b0[vi(0, 0, 1), 1, 35, 31], np.float32(0.42))
ae(b0[vi(-1, 0, 0), 1, 1, 64], np.float32(0.21))
ae(b0[vi(0, -1, 0), 1, 62, 1], np.float32(0.22))
ae(b0[vi(0, 0, -1), 66, 1, 1], np.float32(0.23))
ae(b0[vi(-1, -1, 0), 1, 62, 64], np.float32(0.24))
ae(b0[vi(0, -1, -1), 66, 62, 1], np.float32(0.25))
ae(b0[vi(-1, 0, -1), 66, 1, 64], np.float32(0.26))
ae(b0[vi(-1, 0, 0), 32, 1, 64], np.float32(0.31))
ae(b0[vi(-1, -1, 0), 32, 1, 64], np.float32(0.32))
开发者ID:Mokosha,项目名称:sailfish,代码行数:29,代码来源:3d_propagation.py
示例5: test_horiz_2blocks
def test_horiz_2blocks(self):
global blocks, output
output = os.path.join(tmpdir, 'horiz_2block')
blocks = 2
ctrl = LBSimulationController(SimulationTest, SphereGeometry)
ctrl.run(ignore_cmdline=True)
util.verify_fields(self.ref, output, self.digits, MAX_ITERS)
开发者ID:Mokosha,项目名称:sailfish,代码行数:7,代码来源:3d_sphere.py
示例6: test_3d
def test_3d(self):
s = settings
s.update({
'lat_nx': NX,
'lat_ny': NY,
'lat_nz': NZ})
TestSim.subdomain = TestSubdomain3D
TestSim.subdomain_runner = TestSubdomainRunner3D
ctrl = LBSimulationController(TestSim, default_config=s)
ctrl.run(ignore_cmdline=True)
sim = ctrl.master.sim
# reduction over Z, Y
np.testing.assert_array_almost_equal(
ctrl.master.runner.ret_x,
np.sum(np.sum(sim.data, axis=0), axis=0))
# reduction over Z, X
np.testing.assert_array_almost_equal(
ctrl.master.runner.ret_y,
np.sum(np.sum(sim.data, axis=0), axis=1))
# reduction over Y, X
np.testing.assert_array_almost_equal(
ctrl.master.runner.ret_z,
np.sum(np.sum(sim.data, axis=1), axis=1))
开发者ID:mjanusz,项目名称:sailfish,代码行数:28,代码来源:reduction.py
示例7: test_vert_spread
def test_vert_spread(self):
def ic(self, runner):
dbuf = runner._debug_get_dist()
dbuf[:] = 0.0
if runner._spec.id == 0:
dbuf[vi(-1, 1), 128, 64] = 0.11
dbuf[vi(0, 1), 128, 64] = 0.12
dbuf[vi(1, 1), 128, 64] = 0.13
runner._debug_set_dist(dbuf)
VertTest = type("VertTest", (AASimulationTest,), {"initial_conditions": ic})
ctrl = LBSimulationController(VertTest, Vertical2BlockGeo)
ctrl.run(ignore_cmdline=True)
output = os.path.join(tmpdir, "test_out")
b0 = np.load(io.dists_filename(output, 1, 0, 1))["arr_0"]
b1 = np.load(io.dists_filename(output, 1, 1, 1))["arr_0"]
ae = np.testing.assert_equal
# No propagation in the first step, but the distributions are stored
# in opposite slots.
ae(b1[vi(1, -1), 0, 64], np.float32(0.11))
ae(b1[vi(0, -1), 0, 64], np.float32(0.12))
ae(b1[vi(-1, -1), 0, 64], np.float32(0.13))
开发者ID:hyln9,项目名称:sailfish,代码行数:26,代码来源:2d_propagation.py
示例8: run_test
def run_test(name, re, max_iters, i):
print("Testing Re = %s" % re)
basepath = os.path.join("results", name, "re%s" % re)
if not os.path.exists(basepath):
os.makedirs(basepath)
ctrl = LBSimulationController(TestLDCSim, default_config={"re": re, "max_iters": max_iters})
ctrl.run(ignore_cmdline=True)
horiz = np.loadtxt("ldc_golden/vx2d", skiprows=4)
vert = np.loadtxt("ldc_golden/vy2d", skiprows=4)
plt.plot(horiz[:, 0] * 2 - 1, horiz[:, i], ".", label="Paper")
plt.plot(vert[:, i], 2 * (vert[:, 0] - 0.5), ".", label="Paper")
save_output(basepath, max_iters)
plt.legend(loc="lower right")
plt.gca().yaxis.grid(True)
plt.gca().xaxis.grid(True)
plt.gca().xaxis.grid(True, which="minor")
plt.gca().yaxis.grid(True, which="minor")
plt.title("2D Lid Driven Cavity, Re = %s" % re)
print(os.path.join(basepath, "results.pdf"))
plt.savefig(os.path.join(basepath, "results.pdf"), format="pdf")
plt.clf()
plt.cla()
plt.show()
开发者ID:mjanusz,项目名称:sailfish,代码行数:28,代码来源:ldc_2d.py
示例9: test_horiz_spread
def test_horiz_spread(self):
def ic(self, runner):
dbuf = runner._debug_get_dist()
dbuf[:] = 0.0
if runner._spec.id == 0:
dbuf[vi(1, 0), 64, 128] = 0.11
dbuf[vi(1, 1), 64, 128] = 0.12
dbuf[vi(1, -1), 64, 128] = 0.13
runner._debug_set_dist(dbuf)
HorizTest = type('HorizTest', (AASimulationTest,),
{'initial_conditions': ic})
ctrl = LBSimulationController(HorizTest, DoubleBlockGeometryTest)
ctrl.run(ignore_cmdline=True)
output = os.path.join(tmpdir, 'test_out')
b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']
ae = np.testing.assert_equal
# No propagation in the first step, but the distributions are stored
# in opposite slots.
ae(b1[vi(-1, 0), 64, 0], np.float32(0.11))
ae(b1[vi(-1, -1), 64, 0], np.float32(0.12))
ae(b1[vi(-1, 1), 64, 0], np.float32(0.13))
开发者ID:gexueyuan,项目名称:sailfish,代码行数:27,代码来源:2d_propagation.py
示例10: test_3d
def test_3d(self):
settings = {
'debug_single_process': True,
'quiet': True,
'check_invalid_results_gpu': False,
'check_invalid_results_host': False,
'max_iters': 1,
'lat_nx': NX,
'lat_ny': NY,
'lat_nz': NZ}
ctrl = LBSimulationController(TestSim, default_config=settings)
ctrl.run(ignore_cmdline=True)
sim = ctrl.master.sim
vort = util.vorticity(sim.v)
vort_sq = vort[0]**2 + vort[1]**2 + vort[2]**2
# Convert the velocity field to double precision.
dbl_v = [x.astype(np.float64) for x in sim.v]
self.assertAlmostEqual(util.kinetic_energy(dbl_v), sim.kinetic_energy)
self.assertAlmostEqual(util.enstrophy(dbl_v, dx=1.0), sim.enstrophy)
np.testing.assert_array_almost_equal(sim.v_sq, sim.vx**2 + sim.vy**2 + sim.vz**2)
np.testing.assert_array_almost_equal(sim.vort_sq, vort_sq)
开发者ID:PokerN,项目名称:sailfish,代码行数:26,代码来源:kinetic_energy_enstrophy.py
示例11: test_corner_global_periodic
def test_corner_global_periodic(self):
global tmpdir, periodic_y
periodic_y = True
def ic(self, runner):
dbuf = runner._debug_get_dist()
dbuf[:] = 0.0
dbuf[vi(1, 1), 256, 256] = 0.11
dbuf[vi(-1, -1), 1, 1] = 0.12
dbuf[vi(1, -1), 1, 256] = 0.13
dbuf[vi(-1, 1), 256, 1] = 0.14
runner._debug_set_dist(dbuf)
runner._debug_set_dist(dbuf, False)
CornerTest = type("CornerTest", (SimulationTest,), {"initial_conditions": ic})
ctrl = LBSimulationController(CornerTest)
ctrl.run(ignore_cmdline=True)
output = os.path.join(tmpdir, "test_out")
b0 = np.load(io.dists_filename(output, 1, 0, 1))["arr_0"]
ae = np.testing.assert_equal
ae(b0[vi(1, 1), 1, 1], np.float32(0.11))
ae(b0[vi(-1, -1), 256, 256], np.float32(0.12))
ae(b0[vi(1, -1), 256, 1], np.float32(0.13))
ae(b0[vi(-1, 1), 1, 256], np.float32(0.14))
开发者ID:hyln9,项目名称:sailfish,代码行数:26,代码来源:2d_propagation.py
示例12: run_test
def run_test(name, i):
global RE
RE = reynolds[i]
global MAX_ITERS
MAX_ITERS = max_iters[i]
basepath = os.path.join('results', name, 're%s' % RE)
if not os.path.exists(basepath):
os.makedirs(basepath)
ctrl = LBSimulationController(TestLDCSim, TestLDCGeometry)
ctrl.run()
horiz = np.loadtxt('ldc_golden/vx2d', skiprows=4)
vert = np.loadtxt('ldc_golden/vy2d', skiprows=4)
plt.plot(horiz[:, 0] * 2 - 1, horiz[:, i+1], label='Paper')
plt.plot(vert[:, i+1], 2 * (vert[:, 0] - 0.5), label='Paper')
save_output(basepath)
plt.legend(loc='lower right')
plt.gca().yaxis.grid(True)
plt.gca().xaxis.grid(True)
plt.gca().xaxis.grid(True, which='minor')
plt.gca().yaxis.grid(True, which='minor')
plt.title('Lid Driven Cavity, Re = %s' % RE)
print os.path.join(basepath, 'results.pdf')
plt.savefig(os.path.join(basepath, 'results.pdf'), format='pdf')
plt.clf()
plt.cla()
plt.show()
开发者ID:Mokosha,项目名称:sailfish,代码行数:30,代码来源:ldc_2d.py
示例13: run_test
def run_test(name):
basepath = os.path.join('results', name)
if not os.path.exists(basepath):
os.makedirs(basepath)
ctrl = LBSimulationController(TestLDCSim)
ctrl.run(ignore_cmdline=True)
horiz = np.loadtxt('ldc_golden/re400_horiz', skiprows=1)
vert = np.loadtxt('ldc_golden/re400_vert', skiprows=1)
plt.plot(2 * (horiz[:,0] - 0.5), -2 * (horiz[:,1] - 0.5), '.', label='Sheu, Tsai paper')
plt.plot(2 * (vert[:,0] - 0.5), -2 * (vert[:,1] - 0.5), '.', label='Sheu, Tsai paper')
save_output(basepath, MAX_ITERS)
plt.legend(loc='lower right')
plt.gca().yaxis.grid(True)
plt.gca().xaxis.grid(True)
plt.gca().xaxis.grid(True, which='minor')
plt.gca().yaxis.grid(True, which='minor')
plt.title('Lid Driven Cavity, Re = 400')
print os.path.join(basepath, 're400.pdf' )
plt.savefig(os.path.join(basepath, 're400.pdf' ), format='pdf')
plt.clf()
plt.cla()
plt.show()
shutil.rmtree(tmpdir)
开发者ID:PokerN,项目名称:sailfish,代码行数:27,代码来源:ldc_3d.py
示例14: test_sizes
def test_sizes(sizes, geo_cls):
for w, h, d in sizes:
print 'Testing {0} x {1} x {2}...'.format(w, h, d)
settings.update({'lat_nx': int(w), 'lat_ny': int(h), 'lat_nz': int(d)})
ctrl = LBSimulationController(LDCSim, geo_cls, settings)
timing_infos, blocks = ctrl.run()
summary.append(util.summarize(timing_infos, blocks))
timings.append(timing_infos)
开发者ID:Mokosha,项目名称:sailfish,代码行数:8,代码来源:3d_2blocks.py
示例15: setUpClass
def setUpClass(cls):
global blocks, output
output = os.path.join(tmpdir, 'href')
blocks = 1
ctrl = LBSimulationController(SimulationTest, SphereGeometry)
ctrl.run(ignore_cmdline=True)
cls.digits = io.filename_iter_digits(MAX_ITERS)
cls.ref = np.load(io.filename(output, cls.digits, 0, MAX_ITERS))
开发者ID:Mokosha,项目名称:sailfish,代码行数:8,代码来源:3d_sphere.py
示例16: test_sizes
def test_sizes(sizes):
for w, h in sizes:
print "Testing {0} x {1}...".format(w, h)
settings.update({"lat_nx": int(w), "lat_ny": int(h)})
ctrl = LBSimulationController(LDCSim, LBGeometry2D, settings)
timing_infos, blocks = ctrl.run()
summary.append(util.summarize(timing_infos, blocks))
timings.append(timing_infos)
开发者ID:hyln9,项目名称:sailfish,代码行数:8,代码来源:2d_1block.py
示例17: test_b0_spread
def test_b0_spread(self):
global tmpdir
def ic(self, runner):
dbuf = runner._debug_get_dist()
dbuf[:] = 0.0
if runner._spec.id == 0:
# Top right corner
dbuf[vi(1, 1), 128, 128] = 0.11
dbuf[vi(0, 1), 128, 128] = 0.01
dbuf[vi(1, 0), 128, 128] = 0.10
dbuf[vi(0, -1), 128, 128] = 0.02
dbuf[vi(-1, 0), 128, 128] = 0.20
dbuf[vi(1, -1), 128, 128] = 0.30
dbuf[vi(-1, 1), 128, 128] = 0.40
# Bottom right corner
dbuf[vi(1, 1), 1, 128] = 0.50
dbuf[vi(1, -1), 1, 128] = 0.51
dbuf[vi(1, 0), 1, 128] = 0.52
elif runner._spec.id == 1:
dbuf[vi(1, 0), 127, 128] = 0.60
dbuf[vi(1, 1), 127, 128] = 0.61
dbuf[vi(1, -1), 127, 128] = 0.62
dbuf[vi(1, 0), 128, 128] = 0.70
dbuf[vi(1, -1), 128, 128] = 0.71
runner._debug_set_dist(dbuf)
runner._debug_set_dist(dbuf, False)
RightSide = type("RightSide", (SimulationTest,), {"initial_conditions": ic})
ctrl = LBSimulationController(RightSide, GeometryTest)
ctrl.run(ignore_cmdline=True)
output = os.path.join(tmpdir, "test_out")
b0 = np.load(io.dists_filename(output, 1, 0, 1))["arr_0"]
b1 = np.load(io.dists_filename(output, 1, 1, 1))["arr_0"]
b2 = np.load(io.dists_filename(output, 1, 2, 1))["arr_0"]
b3 = np.load(io.dists_filename(output, 1, 3, 1))["arr_0"]
ae = np.testing.assert_equal
ae(b3[vi(1, 1), 1, 1], np.float32(0.11))
ae(b0[vi(-1, 0), 128, 127], np.float32(0.20))
ae(b0[vi(0, -1), 127, 128], np.float32(0.02))
ae(b2[vi(1, 0), 128, 1], np.float32(0.10))
ae(b1[vi(0, 1), 1, 128], np.float32(0.01))
ae(b2[vi(1, -1), 127, 1], np.float32(0.30))
ae(b1[vi(-1, 1), 1, 127], np.float32(0.40))
ae(b2[vi(1, 1), 2, 1], np.float32(0.50))
ae(b2[vi(1, 0), 1, 1], np.float32(0.52))
ae(b3[vi(1, 0), 127, 1], np.float32(0.60))
ae(b3[vi(1, 0), 128, 1], np.float32(0.70))
ae(b3[vi(1, 1), 128, 1], np.float32(0.61))
ae(b3[vi(1, -1), 127, 1], np.float32(0.71))
ae(b3[vi(1, -1), 126, 1], np.float32(0.62))
开发者ID:hyln9,项目名称:sailfish,代码行数:57,代码来源:2d_propagation.py
示例18: test_depth_spread
def test_depth_spread(self):
global tmpdir
DepthTest = type('DepthTest', (SimulationTest,), {'axis': 2})
ctrl = LBSimulationController(DepthTest, TwoBlocksZConnGeoTest)
ctrl.run(ignore_cmdline=True)
output = os.path.join(tmpdir, 'test_out')
b0 = np.load(io.dists_filename(output, 1, 0, 1))
b1 = np.load(io.dists_filename(output, 1, 1, 1))
self._verify(b0, b1, DepthTest)
开发者ID:Mokosha,项目名称:sailfish,代码行数:10,代码来源:3d_propagation.py
示例19: test_vert_spread
def test_vert_spread(self):
global tmpdir
VertTest = type('VertTest', (SimulationTest,), {'axis': 1})
ctrl = LBSimulationController(VertTest, TwoBlocksYConnGeoTest)
ctrl.run(ignore_cmdline=True)
output = os.path.join(tmpdir, 'test_out')
b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']
self._verify(b0, b1, VertTest)
开发者ID:PokerN,项目名称:sailfish,代码行数:10,代码来源:3d_propagation.py
示例20: test_2subdomains
def test_2subdomains(self):
ctrl = LBSimulationController(AASimulationTest2,
EqualSubdomainsGeometry3D)
ctrl.run(ignore_cmdline=True)
output = os.path.join(tmpdir, 'test_out')
b0 = np.load(io.dists_filename(output, 1, 0, 2))['arr_0']
b1 = np.load(io.dists_filename(output, 1, 1, 2))['arr_0']
ae = np.testing.assert_equal
ae(b0[vi(0, 1, -1), 40, 39, 10], np.float32(0.11))
开发者ID:PokerN,项目名称:sailfish,代码行数:11,代码来源:3d_propagation.py
注:本文中的sailfish.controller.LBSimulationController类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论