def test11(self): instance = Adcirc(**default_options) instance.set_rootdir("data/test/2d") instance.evolve_model( 1 | units.hour) self.assertEqual(instance.model_time, 21*174.656| units.s) self.assertEqual(instance.nodes.status, 'wet') self.assertEqual(instance.elements.status, 'wet') instance.nodes[12].eta=0.21 | units.m self.assertEqual(instance.nodes[12].eta,0.21 | units.m) instance.nodes[12].status='dry' self.assertEqual(instance.nodes[12].status,'dry') self.assertEqual(instance.nodes[12].eta,-instance.nodes[12].depth) instance.nodes[11].deta_dt=0.1 | units.m/units.s self.assertEqual(instance.nodes[11].deta_dt,0.1 | units.m/units.s) instance.nodes[11].eta=0.21 | units.m self.assertEqual(instance.nodes[11].eta,0.21 | units.m) instance.nodes[21].vx=0.21 | units.m/units.s self.assertEqual(instance.nodes[21].vx,0.21 | units.m/units.s) instance.nodes[21].vy=0.21 | units.m/units.s self.assertEqual(instance.nodes[21].vy,0.21 | units.m/units.s) instance.stop()
def test12(self): instance = Adcirc(**default_options) instance.set_rootdir("data/test/2d") instance.commit_parameters() ref=instance.parameters.atmospheric_reference_pressure self.assertEqual(len(instance.nodes),63) self.assertEqual(len(instance.elements),96) self.assertEqual(len(instance.forcings),63) self.assertEqual(instance.forcings.coriolis_f, (63*[0.0])| units.s**-1) self.assertEqual(instance.forcings.tau_x, ([0.0])| units.Pa) self.assertEqual(instance.forcings.tau_y, ([0.0])| units.Pa) self.assertEqual(instance.forcings.pressure, ref) instance.forcings.coriolis_f=numpy.arange(63) | units.s**-1 self.assertEqual(instance.forcings.coriolis_f, list(range(63))| units.s**-1) forcings=instance.forcings.empty_copy() forcings.tau_x=(numpy.arange(63)+123) | units.Pa forcings.tau_y=numpy.arange(63) | units.Pa forcings.pressure=(numpy.arange(63)+321.) | units.Pa forcings.new_channel_to(instance.forcings).copy_attributes(["pressure","tau_x","tau_y"]) self.assertAlmostEqual(instance.forcings.pressure, list(range(321,321+63))| units.Pa,10) self.assertEqual(instance.forcings.tau_x, list(range(123,123+63))| units.Pa) self.assertEqual(instance.forcings.tau_y, list(range(63))| units.Pa) instance.stop()
def test3(self): instance = Adcirc(**default_options) instance.initialize_code() instance.set_rootdir("data/test/2d") instance.commit_parameters() self.assertEqual(len(instance.nodes),63) self.assertEqual(len(instance.elements),96) self.assertEqual(len(instance.forcings),63) self.assertEqual(instance.forcings.coriolis_f, (63*[0.0])| units.s**-1) self.assertEqual(instance.forcings.tau_x, ([0.0])| units.Pa) self.assertEqual(instance.forcings.tau_y, ([0.0])| units.Pa) instance.forcings.coriolis_f=numpy.arange(63) | units.s**-1 self.assertEqual(instance.forcings.coriolis_f, list(range(63))| units.s**-1) forcings=instance.forcings.empty_copy() forcings.tau_x=(numpy.arange(63)+123) | units.Pa forcings.tau_y=numpy.arange(63) | units.Pa forcings.new_channel_to(instance.forcings).copy_attributes(["tau_x","tau_y"]) self.assertEqual(instance.forcings.tau_x, list(range(123,123+63))| units.Pa) self.assertEqual(instance.forcings.tau_y, list(range(63))| units.Pa) instance.cleanup_code() instance.stop()
def test1(self): print("Test 1: rootdir") instance = Adcirc(**default_options) instance.set_rootdir("data/test/2d") rootdir=instance.get_rootdir() self.assertEqual(rootdir,"data/test/2d") instance.cleanup_code() instance.stop()
def test5(self): instance = Adcirc(**default_options) instance.initialize_code() instance.set_rootdir("data/test/2d") instance.commit_parameters() depth=instance.nodes.depth[[0,10]] self.assertEqual(depth,[3.0480,9.3345] | units.m) instance.cleanup_code() instance.stop()
def test6(self): instance = Adcirc(mode="3D",**default_options) instance.initialize_code() instance.set_rootdir("data/test/3d") instance.commit_parameters() vx=instance.nodes[11].wx vy=instance.nodes[11].wy vz=instance.nodes[11].wz self.assertEqual(vx.number,[0.]*21) instance.cleanup_code() instance.stop()
def test4(self): instance = Adcirc(mode="3D",**default_options) instance.initialize_code() instance.set_rootdir("data/test/3d") instance.commit_parameters() a,b=1.,-1. sigma=numpy.arange(21)*0.1-1. z=(sigma-a)/(a-b)*(12.1920| units.m)-instance.nodes[11].eta self.assertEqual(instance.nodes[11].sigma,sigma) self.assertEqual(instance.nodes[11].z,z) instance.cleanup_code() instance.stop()
def test10(self): instance = Adcirc(**default_options) instance.set_rootdir("data/test/2d") print(instance.parameters) instance.evolve_model( 1 | units.hour) self.assertEqual(instance.model_time, 21*174.656| units.s) self.assertEqual(instance.nodes.status, 'wet') self.assertEqual(instance.elements.status, 'wet') instance.stop()
def test2(self): print("Test 1: parameters") instance = Adcirc(**default_options) instance.initialize_code() instance.set_rootdir("data/test/2d") instance.commit_parameters() self.assertEqual(instance.parameters.use_interface_elevation_boundary, False) self.assertEqual(instance.parameters.use_interface_met_forcing, False) instance.parameters.use_interface_elevation_boundary=True instance.parameters.use_interface_met_forcing=True self.assertEqual(instance.parameters.use_interface_elevation_boundary, True) self.assertEqual(instance.parameters.use_interface_met_forcing, True) self.assertEqual(instance.parameters.bottom_friction_law, "linear") self.assertEqual(instance.parameters.linear_bottom_friction_coeff, 0. | units.s**-1) self.assertEqual(instance.parameters.quadratic_bottom_friction_coeff, 0. ) self.assertEqual(instance.parameters.GWCE_weighting_factor, 0.005 ) instance.cleanup_code() instance.stop()
def initialize_adcirc(self): self.read_adcirc_grid("grid.input") param=adcirc_parameter_reader("param.input") param.read_parameters(NETA=self._neta, NFLUX=self._nflux) #~ param.parameters['NBFR']=-1 param.parameters['NWS']=0 adcirc=Adcirc(coordinates="spherical", redirection="file",redirect_stdout_file="adcirc.out") adcirc.set_rootdir(os.getcwd()) #~ adcirc._parameters=param.parameters adcirc._parameters=get_default_parameter_set() adcirc._parameters["NCOR"]=1 # set coriolis f internally adcirc.assign_grid_and_boundary(self.nodes, self.elements, self._elev_boundaries, self._flow_boundaries) adcirc.parameters.use_interface_parameters=True adcirc.parameters.use_interface_grid=True if self.boundary_forcing=="elevation": adcirc.parameters.use_interface_elevation_boundary=True elif self.boundary_forcing=="flow": adcirc.parameters.use_interface_flow_boundary=True adcirc.parameters.use_interface_met_forcing=True adcirc.parameters.A_H=1000. | units.m**2/units.s #~ adcirc.parameters.A_H=param.parameters["ESLM"] | units.m**2/units.s timestep=self.timestep n=1 #~ while timestep>abs(param.parameters["DTDP"]) | units.s: while timestep>300. | units.s: n+=1 timestep=timestep/n adcirc.parameters.timestep=timestep #~ adcirc.parameters.bottom_friction_law=["linear","quadratic","hybrid"][param.parameters["NOLIBF"]] #~ adcirc.parameters.linear_bottom_friction_coeff=param.parameters["TAU"]| units.s**-1 adcirc.parameters.bottom_friction_law="hybrid" adcirc.parameters.hybrid_bottom_friction_hbreak=50. | units.m #~ adcirc.parameters.bottom_friction_law="linear" #~ adcirc.parameters.linear_bottom_friction_coeff=0.00001| units.s**-1 adcirc.parameters.quadratic_bottom_friction_coeff=0.003#param.parameters["CF"] adcirc.parameters.use_predictor_corrector=True#param.parameters["DTDP"]<0 adcirc.parameters.central_longitude=param.parameters["SLAM0"] | units.deg adcirc.parameters.central_latitude=param.parameters["SFEA0"] | units.deg adcirc.parameters.GWCE_weighting_factor=-1.#param.parameters["TAU0"] #~ adcirc.parameters.GWCE_weighting_factor=0.005 #~ adcirc.parameters.spatial_derivative_advective_term_parameter=0 #~ adcirc.parameters.time_derivative_advective_term_parameter=0 #~ adcirc.parameters.finite_amplitude_term_parameter=0 adcirc.parameters.minimum_depth=5.| units.m if self.adcirc_ramp: adcirc.parameters.use_ramping=True adcirc.parameters.ramping_time=self.adcirc_ramp print(adcirc.parameters) self.adcirc=adcirc self.adcirc_grid=adcirc.get_grid() self.adcirc_forcings_grid=StaggeredGrid(self.adcirc_grid.elements, nodes=adcirc.forcings) elements=adcirc.elements.copy(filter_attributes=lambda x,y: y in ["lat","lon","n1","n2","n3"] ) nodes=adcirc.nodes.copy(filter_attributes=lambda x,y: y in ["lat","lon"] ) self.adcirc_memory_grid = StaggeredGrid( elements, nodes=nodes )