示例#1
0
    def test1(self):
        instance = QGmodelInterface()
        instance.initialize_code()

        for key, val in [("Lx", 4000000.), ("Ly", 4000000.), ("dx", 10000.),
                         ("dy", 10000.), ("dt", 3600.), ("H", 4000.),
                         ("rho", 1000.), ("beta0", 1.8616e-11), ("tau", 0.05),
                         ("R_H", 0), ("A_H", 100), ("lambda0", 0.),
                         ("lambda1", 2.e-5), ("Nm", 1), ("begin_time", 0.),
                         ("wind_sigma", -99.), ("e111", 0),
                         ("phi1z0", 1.4142135623731), ("ra_alpha", 0.1),
                         ("interface_wind", 0), ("raw_alpha", 1.0),
                         ("timestep_method", "leapfrog")]:
            result, err = getattr(instance, 'get_' + key)()
            self.assertEquals(result, val)
            newvalue = type(val)(123.)
            err = getattr(instance, 'set_' + key)(newvalue)
            result, err = getattr(instance, 'get_' + key)()
            self.assertEquals(result, newvalue)

        instance.stop()
示例#2
0
def low_level():

    q = QGmodelInterface(redirection="none")

    print 1
    q.initialize_code()
    print 2

    q.set_Lx(4.e6)
    q.set_Ly(4.e6)
    q.set_dx(1.e4)
    q.set_dy(1.e4)
    q.set_dt(1800)

    q.commit_parameters()
    print 3

    q.initialize_grid()
    print 4

    q.evolve_model(86400.)
    print 5
    print q.get_time()

    x, y = numpy.mgrid[0:400, 0:400]

    x = x.flatten() + 1
    y = y.flatten() + 1

    psi, err = q.get_psi1_state(x, y, 1)

    psi = psi.reshape((400, 400))

    print psi.shape
    pyplot.imshow(psi)

    pyplot.show()
示例#3
0
    def test3(self):
        instance = QGmodelInterface()
        instance.initialize_code()

        instance.commit_parameters()

        psi, err = instance.get_psi1_state(1, 1, 1)
        self.assertEqual(psi, 0.)

        Nx, err = instance.get_Nx()
        Ny, err = instance.get_Ny()

        psi, err = instance.get_psi1_state(Nx, Ny, 1)
        self.assertEqual(psi, 0.)

        instance.stop()
示例#4
0
    def test2(self):
        instance = QGmodelInterface()
        instance.initialize_code()

        err = instance.set_Lx(100.)
        err = instance.set_dx(1)
        err = instance.set_Ly(1000.)
        err = instance.set_dy(20)

        instance.commit_parameters()

        Nx, err = instance.get_Nx()
        self.assertEquals(Nx, 101)
        Ny, err = instance.get_Ny()
        self.assertEquals(Ny, 51)

        instance.stop()
示例#5
0
    def test1b(self):
        instance = QGmodelInterface()
        instance.initialize_code()

        lowx, highx, lowy, highy, err = instance.get_boundary_conditions()
        for x in [lowx, highx, lowy, highy]:
            self.assertEqual(x, "free_slip")

        instance.set_boundary_conditions("no_slip", "interface", "interface",
                                         "no_slip")
        lowx, highx, lowy, highy, err = instance.get_boundary_conditions()
        self.assertEqual(lowx, "no_slip")
        self.assertEqual(highy, "no_slip")
        self.assertEqual(lowy, "interface")
        self.assertEqual(highx, "interface")

        # check for failure
        err = instance.set_boundary_conditions("no_slip", "interface",
                                               "interface", "wrong")
        self.assertEqual(err, 8)

        instance.stop()
示例#6
0
 def test0(self):
     instance = QGmodelInterface()
     instance.initialize_code()
     instance.stop()
示例#7
0
    def test5(self):
        instance = QGmodelInterface()
        instance.initialize_code()
        instance.commit_parameters()
        Nx, err = instance.get_Nx()
        Ny, err = instance.get_Ny()
        Nm, err = instance.get_Nm()

        minx, maxx, miny, maxy, minz, maxz, err = instance.get_index_range_inclusive(
        )
        self.assertEqual(minx, 1)
        self.assertEqual(miny, 1)
        self.assertEqual(minz, 1)
        self.assertEqual(maxx, Nx)
        self.assertEqual(maxy, Ny)
        self.assertEqual(maxz, Nm)

        instance.stop()
示例#8
0
    def test4(self):
        instance = QGmodelInterface(redirection="none")
        instance.initialize_code()

        instance.commit_parameters()

        instance.evolve_model(3600.)
        time, err = instance.get_time()
        self.assertEqual(time, 3600.)
        instance.stop()