コード例 #1
0
 def empirical_model(self, ua=None, report=False, base_name=None):
     """
     Run the empirical model defined by the scale equations
     
     """
     # Create a params.Scales object for the empirical model
     epm = params.Scales(self.profile, self.particles)
     
     # Get the ambient velocity
     if ua is None:
         self.ua = self.profile.get_values(self.X[2], 'ua')
     
     # Compute the predictions from the model
     self.h_T = epm.h_T(self.X[2])
     self.h_P = epm.h_P(self.X[2])
     self.h_S = epm.h_S(self.X[2], ua)
     self.u_inf_crit = epm.u_inf_crit(self.X[2])
     
     # Echo solution to the screen if requested
     if report:
         epm.simulate(self.X[2], ua)
     
     # Save the data if requested
     if base_name is not None:
         epm.save_txt(self.X[2], ua, base_name, self.profile_path, 
                      self.profile_info)
コード例 #2
0
def test_params_module():
    """
    Test the class and methods in the `params` module
    
    Test the `params.Scales` class object and the output from its methods
    for a typical plume simulation of a subsea oil well blowout.  This test
    function tests the same calculations as stored in `./bin/params.py`.
    
    """
    # Get the inputs required by the Scales object
    (profile, disp_phases, z0) = get_sim_data()

    # Test that the governing parameters are computed correctly
    # First, test a single dispersed phase
    model = params.Scales(profile, disp_phases[1])
    check_get_variables(model, z0, 0.15, 0.21724144538674975,
                        0.001724100901081246, 0.22611661456807244, 0.15)

    # Second, try a list of dispersed phases, where the dominant phase is
    # not the first one
    particles = [disp_phases[1], disp_phases[0], disp_phases[2]]
    model = params.Scales(profile, particles)
    check_get_variables(model, z0, 0.15, 1.1015134610748201,
                        0.001724100901081246, 0.33764577808309032, 0.15)

    # Third, make sure we get the same answer as the previous case if the
    # particles are in a different order (i.e., the original order)
    model = params.Scales(profile, disp_phases)
    check_get_variables(model, z0, 0.15, 1.1015134610748201,
                        0.001724100901081246, 0.33764577808309032, 0.15)

    # Using the latest Scales object, check that the other methods return
    # the correct results.  Since these methods only depend on the values
    # of B, N, and us computed by the get_variables() method, only one case
    # needs to be tested
    assert_approx_equal(model.h_T(z0), 346.40139518559153, significant=6)
    assert_approx_equal(model.h_P(z0), 627.57408319500291, significant=6)
    assert_approx_equal(model.h_S(z0, 0.15), 295.45365120553163, significant=6)
    assert_approx_equal(model.lambda_1(z0, 0),
                        0.74523735215223819,
                        significant=6)
    assert_approx_equal(model.u_inf_crit(z0),
                        0.063723667111426671,
                        significant=6)
コード例 #3
0
 def correct_lambda_1(self):
     """
     Use `params` to store the correct value of `lambda_1` in particles
     
     """
     # Create a params.Scales object for the empirical model
     epm = params.Scales(self.profile, self.particles)
     
     # Iteratively fill the particles objects with the correct value of
     # lambda_1
     for i in range(len(self.particles)):
         self.particles[i].lambda_1 = epm.lambda_1(self.X[2], i)
コード例 #4
0
    def get_particles(self, composition, data, md_gas0, md_oil0, profile, d50_gas, d50_oil, nbins,
                  T0, z0, dispersant, sigma_fac, oil, mass_frac, hydrate, inert_drop):
        """
        docstring for get_particles

        """

        # Reduce surface tension if dispersant is applied
        if dispersant is True:
            sigma = np.array([[1.], [1.]]) * sigma_fac
        else:
            sigma = np.array([[1.], [1.]])

        # Create DBM objects for the bubbles and droplets
        bubl = dbm.FluidParticle(composition, fp_type=0, sigma_correction=sigma[0], user_data=data)
        drop = dbm.FluidParticle(composition, fp_type=1, sigma_correction=sigma[1], user_data=data)

        # Get the local ocean conditions
        T, S, P = profile.get_values(z0, ['temperature', 'salinity', 'pressure'])
        rho = seawater.density(T, S, P)

        # Get the mole fractions of the released fluids
        molf_gas = bubl.mol_frac(md_gas0)
        molf_oil = drop.mol_frac(md_oil0)
        print molf_gas
        print molf_oil

        # Use the Rosin-Rammler distribution to get the mass flux in each
        # size class
#        de_gas, md_gas = sintef.rosin_rammler(nbins, d50_gas, np.sum(md_gas0),
#                                              bubl.interface_tension(md_gas0, T0, S, P),
#                                              bubl.density(md_gas0, T0, P), rho)
#        de_oil, md_oil = sintef.rosin_rammler(nbins, d50_oil, np.sum(md_oil0),
#                                              drop.interface_tension(md_oil0, T0, S, P),
#                                              drop.density(md_oil0, T0, P), rho)

        # Get the user defined particle size distibution
        de_oil, vf_oil, de_gas, vf_gas = self.userdefined_de()
        md_gas = np.sum(md_gas0) * vf_gas
        md_oil = np.sum(md_oil0) * vf_oil

        # Define a inert particle to be used if inert liquid particles are use
        # in the simulations
        molf_inert = 1.
        isfluid = True
        iscompressible = True
        rho_o = drop.density(md_oil0, T0, P)
        inert = dbm.InsolubleParticle(isfluid, iscompressible, rho_p=rho_o, gamma=40.,
                                      beta=0.0007, co=2.90075e-9)

        # Create the particle objects
        particles = []
        t_hyd = 0.

        # Bubbles
        for i in range(nbins):
            if md_gas[i] > 0.:
                (m0, T0, nb0, P, Sa, Ta) = dispersed_phases.initial_conditions(
                            profile, z0, bubl, molf_gas, md_gas[i], 2, de_gas[i], T0)
                # Get the hydrate formation time for bubbles
                if hydrate is True and dispersant is False:
                    t_hyd = dispersed_phases.hydrate_formation_time(bubl, z0, m0, T0, profile)
                    if np.isinf(t_hyd):
                        t_hyd = 0.
                else:
                    t_hyd = 0.
                particles.append(bpm.Particle(0., 0., z0, bubl, m0, T0, nb0,
                                              1.0, P, Sa, Ta, K=1., K_T=1., fdis=1.e-6, t_hyd=t_hyd))

        # Droplets
        for i in range(len(de_oil)):
            # Add the live droplets to the particle list
            if md_oil[i] > 0. and not inert_drop:
                (m0, T0, nb0, P, Sa, Ta) = dispersed_phases.initial_conditions(
                        profile, z0, drop, molf_oil, md_oil[i], 2, de_oil[i], T0)
                # Get the hydrate formation time for bubbles
                if hydrate is True and dispersant is False:
                    t_hyd = dispersed_phases.hydrate_formation_time(drop, z0, m0, T0, profile)
                    if np.isinf(t_hyd):
                            t_hyd = 0.
                else:
                    t_hyd = 0.
                particles.append(bpm.Particle(0., 0., z0, drop, m0, T0, nb0,
                                                1.0, P, Sa, Ta, K=1., K_T=1., fdis=1.e-6, t_hyd=t_hyd))
            # Add the inert droplets to the particle list
            if md_oil[i] > 0. and inert_drop is True:
                (m0, T0, nb0, P, Sa, Ta) = dispersed_phases.initial_conditions(
                        profile, z0, inert, molf_oil, md_oil[i], 2, de_oil[i], T0)
                particles.append(bpm.Particle(0., 0., z0, inert, m0, T0, nb0,
                        1.0, P, Sa, Ta, K=1., K_T=1., fdis=1.e-6, t_hyd=0.))

        # Define the lambda for particles
        model = params.Scales(profile, particles)
        for j in range(len(particles)):
            particles[j].lambda_1 = model.lambda_1(z0, j)

        # Return the particle list
        return particles
コード例 #5
0
ファイル: scales.py プロジェクト: changks/tamoc
    # case of an inert oil phase
    oil = dbm.InsolubleParticle(True,
                                True,
                                rho_p=890.,
                                gamma=30.,
                                beta=0.0007,
                                co=2.90075e-9)
    mb0 = 10.  # total mass flux in kg/s
    de = 0.004  # bubble diameter in m
    lambda_1 = 0.9
    disp_phases.append(
        stratified_plume_model.particle_from_mb0(ctd, z0, oil, np.array([1.]),
                                                 mb0, de, lambda_1, T0))

    # Compute the governing scales
    case = params.Scales(ctd, disp_phases)

    (B, N, u_slip, u_inf) = case.get_variables(z0, 0.15)
    print('Plume parameters:')
    print('   z   = %f (m)' % z0)
    print('   B   = %f (m^4/s^3)' % B)
    print('   N   = %f (s^(-1))' % N)
    print('   u_s = %f (m/s)' % u_slip)
    print('   u_a = %f (m/s)\n' % u_inf)

    print('Plume empirical scales:')
    print('   h_T = %f (m)' % case.h_T(z0))
    print('   h_P = %f (m)' % case.h_P(z0))
    print('   h_S = %f (m)' % case.h_S(z0, 0.15))
    print('   lambda_1 = %f (--)\n' % case.lambda_1(z0, 0))