Esempio n. 1
0
    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()
Esempio n. 2
0
    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()
Esempio n. 3
0
    def test8(self):
        instance=Adcirc(**default_options)
        instance.parameters.rootdir="data/test/2d"        

        instance.commit_parameters()
        self.assertEqual(instance.get_name_of_current_state(), "EDIT")
        self.assertRaises(Exception, lambda : setattr(instance.parameters, "use_interface_grid",True),
         expected_message="While calling before_set_interface_parameter of Adcirc: No transition from current state state 'EDIT' to state 'INITIALIZED' possible")
Esempio n. 4
0
 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()
Esempio n. 5
0
 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()
Esempio n. 6
0
 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()
Esempio n. 7
0
    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()
Esempio n. 8
0
    def test7(self):
        instance=Adcirc(**default_options)
        instance.parameters.rootdir="data/test/2d"        

        instance.commit_parameters()
        self.assertEqual(instance.get_name_of_current_state(), "EDIT")