Exemple #1
0
    def __init__(self, options):

        ProblemBase.__init__(self, options)

        try:  # viscosity
            self.nu = options['nu']
        except:
            self.nu = 1E-3

        try:  # Atwood number
            self.At = options['At']
        except:
            self.At = 0.5

        self.Re = d**1.5 * g / self.nu

        # Create mesh
        self.Nx, self.Ny = options['Nx'], options['Ny']
        self.mesh = RectangleMesh(Point(x0, y0), Point(x1, y1), self.Nx,
                                  self.Ny)

        self.t0, self.T, = 0., options['T']
        try:
            self.CFL = options['CFL']
        except:
            self.CFL = 5.
        self.Ubar = g
        self.k = self.time_step(self.Ubar, self.mesh)  # mesh size
Exemple #2
0
    def __init__(self, options):
        ProblemBase.__init__(self, options)

        self.mesh = self.Mesh(options)

        self.t0 = 0.
        try:
            self.T = options['T']
        except:
            self.T = 2

        try:
            self.nu = option['nu']
        except:
            self.nu = 1E-3

        self.At = At
        self.Ubar = 1.
        try:
            self.CFL = options['CFL']
        except:
            self.CFL = 5.
        self.k = self.time_step(self.Ubar, self.mesh)  # mesh size

        # what functional should we use?
        self.functional = self.density
Exemple #3
0
    def __init__(self, options):
        ProblemBase.__init__(self, options)

        # Create mesh

        try:
            domain = options['initial_mesh']
            self.mesh = Mesh(domain)
        except:
            outerRect = Rectangle(Xmin, Ymin, Xmax, Ymax)
            innerRect = Rectangle(xmin, ymin, xmax, ymax)
            domain = outerRect - innerRect
            self.mesh = generate_mesh(domain, self.Nx)

        self.t0 = 0.
        self.T = options['T']
        self.Ubar = 1.0
        self.k = self.time_step(self.Ubar, self.mesh)

        try:  # set up heat coefficient
            self.kappa = Constant(options['kappa'])
        except:
            self.kappa = kappa
        try:  # velocity for adr
            self.beta = Constant(options['beta'])
        except:
            self.beta = beta
        try:  # reaction coefficient for adr
            self.alpha = Constant(options['alpha'])
        except:
            self.alpha = alpha

        self.rho = rho  # density
        self.c = c
Exemple #4
0
    def __init__(self, options):
        ProblemBase.__init__(self, options)

        try:
            self.potential = options['potential_vorticity']
        except:
            self.potential = False

        self.Nx = options['Nx']
        self.Ny = options['Ny']
        self.mesh = RectangleMesh(Point(0, -1), Point(1, 1), self.Nx, self.Ny)

        # initial time, final time, time-step
        self.t0 = 0.
        self.T = options['T']
        self.Ubar = 2.  # expected time-averaged max streamfunction
        try:
            self.k = options['k']
        except:
            self.k = 0.01
        # self.k = self.time_step(self.Ubar, self.mesh)

        # Reynolds number
        try:
            self.Re = options['Re']
        except:
            self.Re = 200

        # Rossby number
        try:
            self.Ro = options['Ro']
        except:
            self.Ro = 0.0016
Exemple #5
0
    def __init__(self, options):
        ProblemBase.__init__(self, options)

        # Create mesh
        self.Nx = options["Nx"]

        outerRect = Rectangle(Point(Xmin, Ymin), Point(Xmax, Ymax))
        innerRect = Rectangle(Point(xmin, ymin), Point(xmax, ymax))
        domain = outerRect - innerRect
        self.mesh = generate_mesh(domain, self.Nx)

        self.t0 = 0.
        self.T = options['T']
        self.k = options['k']

        # set up heat coefficient
        try:
            self.kappa = Expression('kappa', kappa=options['kappa'])
        except:
            K = np.array([[kappa1, 0], [0, kappa2]])
            Theta = np.array([[cos(theta), -sin(theta)],
                              [sin(theta), cos(theta)]])
            kappa = np.dot(Theta, np.dot(K, np.transpose(Theta)))
            self.kappa = Expression((('k1', 'k2'), ('k3', 'k4')),
                                    k1=kappa[0, 0],
                                    k2=kappa[0, 1],
                                    k3=kappa[1, 0],
                                    k4=kappa[1, 1])

        self.beta = Constant((-1, -0.61))  # velocity for adr

        self.a = 1  # reaction coefficient for adr

        self.rho = rho  # density
        self.c = c
Exemple #6
0
    def __init__(self, options):
        ProblemBase.__init__(self, options)

        self.opt_control = None

        # Create mesh
        Nx = options["Nx"]
        Ny = options["Ny"]

        try:
            x0 = float(options["x0"])
            x1 = float(options["x1"])
            y0 = float(options["y0"])
            y1 = float(options["y1"])
            self.mesh = RectangleMesh(x0, y0, x1, y1, Nx, Ny)
        except:
            self.mesh = UnitSquareMesh(Nx, Ny)

        self.t0 = 0.
        self.T = options['T']
        self.k = options['k']

        try:
            self.kappa = Constant(options['kappa'])
        except:
            self.kappa = Constant(1E-2)  # heat Coefficient
        try:
            self.rho = Constant(options['rho'])
        except:
            self.rho = Constant(1.)  # density

        try:
            self.c = Constant(options['c'])
        except:
            self.c = Constant(1.)  # heat Coefficient
Exemple #7
0
    def __init__(self, options):
        ProblemBase.__init__(self, options)

        # Create mesh
        self.dim = options['dim']
        self.Nx = options["Nx"]
        if self.dim == 3:
            self.uNoSlip = Expression(('0', '0', '0'))
            self.uLid = Expression(('1', '0', '0'))
            domain = Box(Point(0, 0, 0), Point(1, 1, 1))
        else:
            self.uNoSlip = Expression(('0', '0'))
            self.uLid = Expression(('1', '0'))
            domain = Rectangle(Point(0, 0), Point(1, 1))

        self.mesh = generate_mesh(domain, self.Nx)

        self.t0 = 0.
        self.T = options['T']
        self.k = options['k']

        try:
            self.nu = options['nu']
        except:
            self.nu = 1E-3

        self.Re = 1. / self.nu
Exemple #8
0
    def __init__(self, options):
        ProblemBase.__init__(self, options)

        # Create mesh
        self.Nx = options["Nx"]
        self.Ny = options["Ny"]
        self.mesh = RectangleMesh(Point(-1, -1), Point(1, 1), self.Nx, self.Ny)

        self.t0 = 0.
        self.T = options['T']
        self.k = options['k']
Exemple #9
0
    def __init__(self, options):
        ProblemBase.__init__(self, options)

        # Create mesh
        Nx = options["Nx"]
        Ny = options["Ny"]

        self.mesh = UnitSquareMesh(Nx, Ny)

        self.t0 = 0.  # initial time
        self.T = options['T']  # final time
        self.k = options['k']  # time step

        self.kappa = Constant(1E-2)  # heat Coefficient
Exemple #10
0
    def __init__(self, options):
        ProblemBase.__init__(self, options)

        # Create mesh
        Nx = options["Nx"]
        Ny = options["Ny"]
        self.mesh = RectangleMesh(x0, y0, x1, y1, Nx, Ny)

        self.t0 = 0.
        self.T = options['T']
        self.k = options['k']

        self.rho = rho  # density
        self.c = c  # speed of sound

        self.Ug = Expression(('sin(2*pi*f*t)', '0'), f=f, t=self.t0)  # BC
        self.Ud = Ud  # domain velocity
Exemple #11
0
    def __init__(self, options):
        ProblemBase.__init__(self, options)

        # Create mesh
        Nx = options["Nx"]
        Ny = options["Ny"]
        self.mesh = RectangleMesh(x0, y0, x1, y1, Nx, Ny)

        self.t0 = 0.
        self.T = options['T']
        self.k = options['k']

        try:
            self.nu = options['nu']
        except:
            self.nu = 1E-3

        self.Re = (y1 - y0)/self.nu
Exemple #12
0
    def __init__(self, options):
        ProblemBase.__init__(self, options)

        # Create mesh
        Nx = options["Nx"]
        Ny = options["Ny"]

        x0 = 0
        x1 = 1
        y0 = 0
        y1 = 1

        self.p1 = Point(x0 + 0.25 * (x1 - x0), y0 + 0.5 * (y1 - y0))
        self.p2 = Point(x1 - 0.25 * (x1 - x0), y0 + 0.5 * (y1 - y0))
        self.mesh = RectangleMesh(x0, y0, x1, y1, Nx, Ny)

        self.t0 = 0.
        self.T = options['T']
        self.k = options['k']
Exemple #13
0
    def __init__(self, options, cube=False):

        global xmax, xcenter, ycenter

        options['Ny'], options['Nz'] = None, None
        ProblemBase.__init__(self, options)

        self.load_options(options)

        # Load mesh
        self.cube = cube
        self.mesh = self.Mesh(options['initial_mesh'])

        self.t0 = 0.

        self.velocity_functions()  # define U, Ubar, noSlip, and T
        self.k = self.time_step(self.Ubar, self.mesh)  # mesh size

        self.Re = self.Ubar * Diameter / self.nu
Exemple #14
0
    def __init__(self, options):
        ProblemBase.__init__(self, options)

        # Scaling Parameters
        self.sigma = Constant(h0 / lambda0)
        self.epsilon = Constant(a0 / h0)

        # Create mesh
        self.Nx = options['Nx']
        self.Ny = options['Ny']
        self.mesh = RectangleMesh(Point(x0, y0), Point(x1, y1),
                                  self.Nx, self.Ny)

        try:
            refine = options['refine']
        except:
            refine = False

        if refine:
            self.mesh = self.Refine(self.mesh)

        # Scaled Parameters
        self.t0 = 0.
        self.T = options['T'] * c0 / lambda0  # Final time
        self.k = options['k'] * c0 / lambda0  # time step

        # set up the CST shape parameterization
        ObjH = Constant(ad, name='ObjHeight')
        N1 = Constant(1., name='N1')
        N2 = Constant(1., name='N2')
        W1 = Constant(1., name='W1')
        W2 = Constant(1., name='W2')
        W3 = Constant(1., name='W3')
        W4 = Constant(1., name='W4')
        dz = Constant(0., name='dz')

        self.params = [ObjH, N1, N2, W1, W2, W3, W4, dz]

        self.D = Depth()  # pool depth
        self.beta = Expression((('v', '0')), v=vmax)
Exemple #15
0
    def __init__(self, options):
        ProblemBase.__init__(self, options)

        self.dim = options['dim']

        # Create mesh
        Nx = options['Nx']
        Ny = options['Ny']

        if self.dim == 2:
            self.mesh = RectangleMesh(-W / 2., -D, W / 2., 0., Nx, Ny)
        else:
            Nz = options['Nz']
            self.mesh = BoxMesh(-W / 2., -W / 2., -D, W / 2., W / 2., 0., Nx,
                                Ny, Nz)

        self.t0 = 0.
        period = 2. * pi / omega
        self.T = 10. * period
        self.k = period / n

        if self.dim == 2:
            kappa = 'x[0] > -W/4 && x[0] < W/4 '\
                '&& x[1] > -D/2 && x[1] < -D/2 + D/4 ? '\
                'kappa_1 : kappa_0'
        else:
            kappa = 'x[0] > -W/4 && x[0] < W/4 '\
                '&& x[1] > -W/4 && x[1] < W/4 ' \
                '&& x[2] > -D/2 && x[2] < -D/2 + D/4 ? '\
                'kappa_1 : kappa_0'
        self.kappa = Expression(kappa,
                                D=D,
                                W=W,
                                kappa_0=kappa_0,
                                kappa_1=kappa_1)
        self.rho = rho
        self.c = c
Exemple #16
0
    def __init__(self, options, cube=False):

        global xmax, xcenter, ycenter

        # Load mesh
        options['Ny'], options['Nz'] = None, None
        ProblemBase.__init__(self, options)
        self.Nx = options['Nx']

        try:
            self.nu = options['nu']
        except:
            self.nu = 1E-3

        self.t0 = 0.
        try:
            self.T = options['T']
        except:
            self.T = 10

        H = ymax
        # setup our domain and conditions
        try:
            self.mesh = Mesh(options['initial_mesh'])
        except:
            channel = Rectangle(Point(xmin, ymin), Point(xmax, ymax))
            bluff = Circle(Point(xcenter, ycenter), radius)
            domain = channel - bluff
            self.mesh = generate_mesh(domain, self.Nx)

        self.noSlip = Constant((0, 0))
        self.U = Expression(('4*Um*x[1]*(H - x[1])/(H*H)*t*t/(1+t*t)',
                            '0.0'), Um=Um, H=ymax, t=self.t0)
        self.Ubar = 4. / 3. * Um * ymax * (H - ymax / 2.) / (H * H)

        self.k = self.time_step(self.Ubar, self.mesh)  # mesh size