本文整理汇总了Python中anuga.shallow_water.shallow_water_domain.Domain.set_starttime方法的典型用法代码示例。如果您正苦于以下问题:Python Domain.set_starttime方法的具体用法?Python Domain.set_starttime怎么用?Python Domain.set_starttime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anuga.shallow_water.shallow_water_domain.Domain
的用法示例。
在下文中一共展示了Domain.set_starttime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sww2domain_starttime
# 需要导入模块: from anuga.shallow_water.shallow_water_domain import Domain [as 别名]
# 或者: from anuga.shallow_water.shallow_water_domain.Domain import set_starttime [as 别名]
def test_sww2domain_starttime(self):
"""
Crete a domain and set a starttime, store and read back in
using load_sww_as_domain
"""
yiel=0.01
points, vertices, boundary = rectangular(10,10)
#print "=============== boundary rect ======================="
#print boundary
#Create shallow water domain
domain = Domain(points, vertices, boundary)
domain.geo_reference = Geo_reference(56,11,11)
domain.smooth = False
domain.store = True
domain.set_name('bedslope')
domain.default_order=2
domain.set_starttime(200.0)
#Bed-slope and friction
domain.set_quantity('elevation', lambda x,y: -x/3)
domain.set_quantity('friction', 0.1)
# Boundary conditions
from math import sin, pi
Br = Reflective_boundary(domain)
Bt = Transmissive_boundary(domain)
Bd = Dirichlet_boundary([0.2,0.,0.])
Bw = Time_boundary(domain=domain,function=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0])
#domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br})
domain.set_boundary({'left': Bd, 'right': Bd, 'top': Bd, 'bottom': Bd})
domain.quantities_to_be_stored['xmomentum'] = 2
domain.quantities_to_be_stored['ymomentum'] = 2
#Initial condition
h = 0.05
elevation = domain.quantities['elevation'].vertex_values
domain.set_quantity('stage', elevation + h)
domain.check_integrity()
#Evolution
#domain.tight_slope_limiters = 1
for t in domain.evolve(yieldstep = yiel, finaltime = 0.05):
#domain.write_time()
pass
#print boundary
filename = domain.datadir + os.sep + domain.get_name() + '.sww'
domain2 = load_sww_as_domain(filename, None, fail_if_NaN=False,
verbose=self.verbose)
# Unfortunately we loss the boundaries top, bottom, left and right,
# they are now all lumped into "exterior"
#print "=============== boundary domain2 ======================="
#print domain2.boundary
#print domain2.get_boundary_tags()
#points, vertices, boundary = rectangular(15,15)
#domain2.boundary = boundary
###################
##NOW TEST IT!!!
###################
os.remove(filename)
bits = ['vertex_coordinates']
for quantity in ['stage']:
bits.append('get_quantity("%s").get_integral()' % quantity)
bits.append('get_quantity("%s").get_values()' % quantity)
for bit in bits:
#print 'testing that domain.'+bit+' has been restored'
#print bit
#print 'done'
#print eval('domain.'+bit)
#print eval('domain2.'+bit)
assert num.allclose(eval('domain.'+bit),eval('domain2.'+bit))
######################################
#Now evolve them both, just to be sure
######################################x
from time import sleep
final = .1
domain.set_quantity('friction', 0.1)
domain.store = False
domain.set_boundary({'exterior': Bd, 'left' : Bd, 'right': Bd, 'top': Bd, 'bottom': Bd})
for t in domain.evolve(yieldstep = yiel, finaltime = final):
#domain.write_time()
#.........这里部分代码省略.........
示例2: test_file_boundary_stsIV_sinewave_ordering
# 需要导入模块: from anuga.shallow_water.shallow_water_domain import Domain [as 别名]
# 或者: from anuga.shallow_water.shallow_water_domain.Domain import set_starttime [as 别名]
#.........这里部分代码省略.........
xmomentum = fid.variables['xmomentum'][:]
ymomentum = fid.variables['ymomentum'][:]
elevation = fid.variables['elevation'][:]
# Create beginnings of boundary polygon based on sts_boundary
boundary_polygon = create_sts_boundary(base_name)
os.remove(order_file)
# Append the remaining part of the boundary polygon to be defined by
# the user
bounding_polygon_utm=[]
for point in bounding_polygon:
zone,easting,northing=redfearn(point[0],point[1])
bounding_polygon_utm.append([easting,northing])
boundary_polygon.append(bounding_polygon_utm[3])
boundary_polygon.append(bounding_polygon_utm[4])
#print 'boundary_polygon', boundary_polygon
plot=False
if plot:
from pylab import plot,show,axis
boundary_polygon=ensure_numeric(boundary_polygon)
bounding_polygon_utm=ensure_numeric(bounding_polygon_utm)
#plot(lat_long_points[:,0],lat_long_points[:,1],'o')
plot(boundary_polygon[:,0], boundary_polygon[:,1])
plot(bounding_polygon_utm[:,0],bounding_polygon_utm[:,1])
show()
assert num.allclose(bounding_polygon_utm,boundary_polygon)
extent_res=1000000
meshname = 'urs_test_mesh' + '.tsh'
interior_regions=None
boundary_tags={'ocean': [0,1], 'otherocean': [2,3,4]}
# have to change boundary tags from last example because now bounding
# polygon starts in different place.
create_mesh_from_regions(boundary_polygon,
boundary_tags=boundary_tags,
maximum_triangle_area=extent_res,
filename=meshname,
interior_regions=interior_regions,
verbose=False)
domain_fbound = Domain(meshname)
domain_fbound.set_quantity('stage', tide)
Bf = File_boundary(sts_file+'.sts',
domain_fbound,
boundary_polygon=boundary_polygon)
Br = Reflective_boundary(domain_fbound)
domain_fbound.set_boundary({'ocean': Bf,'otherocean': Br})
finaltime=time_step*(time_step_count-1)
yieldstep=time_step
temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.float)
for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep,
finaltime=finaltime,
skip_initial_step=False)):
temp_fbound[i]=domain_fbound.quantities['stage'].centroid_values[2]
domain_time = Domain(meshname)
domain_time.set_quantity('stage', tide)
Br = Reflective_boundary(domain_time)
Bw = Time_boundary(domain=domain_time,
function=lambda t: [num.sin(t)+tide,3.*(20.+num.sin(t)+tide),2.*(20.+num.sin(t)+tide)])
domain_time.set_boundary({'ocean': Bw,'otherocean': Br})
temp_time=num.zeros(int(finaltime/yieldstep)+1,num.float)
domain_time.set_starttime(domain_fbound.get_starttime())
for i, t in enumerate(domain_time.evolve(yieldstep=yieldstep,
finaltime=finaltime,
skip_initial_step=False)):
temp_time[i]=domain_time.quantities['stage'].centroid_values[2]
assert num.allclose(temp_fbound, temp_time)
assert num.allclose(domain_fbound.quantities['stage'].vertex_values,
domain_time.quantities['stage'].vertex_values)
assert num.allclose(domain_fbound.quantities['xmomentum'].vertex_values,
domain_time.quantities['xmomentum'].vertex_values)
assert num.allclose(domain_fbound.quantities['ymomentum'].vertex_values,
domain_time.quantities['ymomentum'].vertex_values)
try:
os.remove(sts_file+'.sts')
except:
# Windoze can't remove this file for some reason
pass
os.remove(meshname)