本文整理汇总了Python中anuga.shallow_water.shallow_water_domain.Domain.get_flow_through_cross_section方法的典型用法代码示例。如果您正苦于以下问题:Python Domain.get_flow_through_cross_section方法的具体用法?Python Domain.get_flow_through_cross_section怎么用?Python Domain.get_flow_through_cross_section使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anuga.shallow_water.shallow_water_domain.Domain
的用法示例。
在下文中一共展示了Domain.get_flow_through_cross_section方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_flow_through_cross_section_with_geo
# 需要导入模块: from anuga.shallow_water.shallow_water_domain import Domain [as 别名]
# 或者: from anuga.shallow_water.shallow_water_domain.Domain import get_flow_through_cross_section [as 别名]
def test_get_flow_through_cross_section_with_geo(self):
"""test_get_flow_through_cross_section(self):
Test that the total flow through a cross section can be
correctly obtained at run-time from the ANUGA domain.
This test creates a flat bed with a known flow through it and tests
that the function correctly returns the expected flow.
The specifics are
e = -1 m
u = 2 m/s
h = 2 m
w = 3 m (width of channel)
q = u*h*w = 12 m^3/s
This run tries it with georeferencing and with elevation = -1
"""
# Create basic mesh (20m x 3m)
width = 3
length = 20
t_end = 1
points, vertices, boundary = rectangular(length, width, length, width)
# Create shallow water domain
domain = Domain(points, vertices, boundary,
geo_reference=Geo_reference(56, 308500, 6189000))
domain.default_order = 2
domain.set_quantities_to_be_stored(None)
e = -1.0
w = 1.0
h = w-e
u = 2.0
uh = u*h
Br = Reflective_boundary(domain) # Side walls
Bd = Dirichlet_boundary([w, uh, 0]) # 2 m/s across the 3 m inlet:
# Initial conditions
domain.set_quantity('elevation', e)
domain.set_quantity('stage', w)
domain.set_quantity('xmomentum', uh)
domain.set_boundary({'left': Bd, 'right': Bd, 'top': Br, 'bottom': Br})
# Interpolation points down the middle
I = [[0, width/2.],
[length/2., width/2.],
[length, width/2.]]
interpolation_points = domain.geo_reference.get_absolute(I)
for t in domain.evolve(yieldstep=0.1, finaltime=0.5):
# Shortcuts to quantites
stage = domain.get_quantity('stage')
xmomentum = domain.get_quantity('xmomentum')
ymomentum = domain.get_quantity('ymomentum')
# Check that quantities are they should be in the interior
w_t = stage.get_values(interpolation_points)
uh_t = xmomentum.get_values(interpolation_points)
vh_t = ymomentum.get_values(interpolation_points)
assert num.allclose(w_t, w)
assert num.allclose(uh_t, uh)
assert num.allclose(vh_t, 0.0, atol=1.0e-6)
# Check flows through the middle
for i in range(5):
x = length/2. + i*0.23674563 # Arbitrary
cross_section = [[x, 0], [x, width]]
cross_section = domain.geo_reference.get_absolute(cross_section)
Q = domain.get_flow_through_cross_section(cross_section,
verbose=False)
assert num.allclose(Q, uh*width)
import cPickle
cPickle.dump(domain, open('domain_pickle.pickle', 'w'))
domain_restored = cPickle.load(open('domain_pickle.pickle'))
for t in domain_restored.evolve(yieldstep=0.1, finaltime=1.0):
# Shortcuts to quantites
stage = domain_restored.get_quantity('stage')
xmomentum = domain_restored.get_quantity('xmomentum')
ymomentum = domain_restored.get_quantity('ymomentum')
# Check that quantities are they should be in the interior
w_t = stage.get_values(interpolation_points)
uh_t = xmomentum.get_values(interpolation_points)
vh_t = ymomentum.get_values(interpolation_points)
assert num.allclose(w_t, w)
assert num.allclose(uh_t, uh)
assert num.allclose(vh_t, 0.0, atol=1.0e-6)
#.........这里部分代码省略.........