Example #1
0
def test_update_current_data():
    """
    Check that the Blowout.update_current_data() method works as 
    anticipated and with no side effects
    
    """
    # Get the input parameters for a typical blowout
    z0, d0, substance, q_oil, gor, x0, y0, u0, phi_0, theta_0, \
        num_gas_elements, num_oil_elements, water, current = \
        get_blowout()
    
    # Create the blowout.Blowout object
    spill = blowout.Blowout(z0, d0, substance, q_oil, gor, x0, y0, u0, phi_0, 
                            theta_0, num_gas_elements, num_oil_elements, 
                            water, current)
    
    # Update the release depth
    current = 0.1
    spill.update_current_data(current)
    
    # Check that things were done correctly
    assert spill.update == False
    assert spill.bpm.sim_stored == False
    check_attributes(z0, d0, substance, q_oil, gor, x0, y0, u0, phi_0, 
                     theta_0, num_gas_elements, num_oil_elements, 
                     water, current, spill)
Example #2
0
def test_simulate():
    """
    Check that the Blowout.simulate() method works and produces the expected
    output.
    
    """
    # Get the input parameters for a typical blowout
    z0, d0, substance, q_oil, gor, x0, y0, u0, phi_0, theta_0, \
        num_gas_elements, num_oil_elements, water, current = \
        get_blowout()
    
    # Create the blowout.Blowout object
    spill = blowout.Blowout(z0, d0, substance, q_oil, gor, x0, y0, u0, phi_0, 
                            theta_0, num_gas_elements, num_oil_elements, 
                            water, current)
    
    # Run the simulation
    # Get the input parameters for a typical blowout
    z0, d0, substance, q_oil, gor, x0, y0, u0, phi_0, theta_0, \
        num_gas_elements, num_oil_elements, water, current = \
        get_blowout()
    
    # Create the blowout.Blowout object
    spill.simulate()
    
    # Check the simulation
    check_simulation(spill)
    
    # Re-run the simulation and make sure the results are unchanged
    spill.simulate()
    check_simulation(spill)
    
    
    
                    
Example #3
0
    q_oil = 20000.  # bbl/d
    gor = 2000.  # ft^3/bbl at standard conditions
    z0 = 1000.  # release depth (m)
    d0 = 0.2  # orifice diameter (m)

    # Import the oil with the desired gas to oil ratio
    oil, mass_flux = dbm_utilities.get_oil(substance, q_oil, gor, ca)

    # Decide on the number of Lagrangian elements to use for gas bubbles
    # and oil droplets
    num_gas_elements = 15
    num_oil_elements = 15

    # Initialize the blowout.Blowout object with these conditions
    spill = blowout.Blowout(z0, d0, substance, q_oil, gor, x0, y0, u0, phi_0,
                            theta_0, num_gas_elements, num_oil_elements, water,
                            current)

    # Run the simulation
    spill.simulate()

    # Plot the trajectory of the plume and the bubbles and droplets in the
    # plume
    spill.plot_state_space(1)

    # Plot all of the simulation variables
    spill.plot_all_variables(10)

    # Change the oil and gas flow rate
    spill.update_q_oil(30000.)
    spill.update_gor(1500.)
Example #4
0
def test_Blowout_inst():
    """
    Test instantiation of a `blowout.Blowout` object
    
    Test that the initializer of the `blowout.Blowout` class creates the 
    correct object
    
    """
    # Get the input parameters for a typical blowout
    z0, d0, substance, q_oil, gor, x0, y0, u0, phi_0, theta_0, \
        num_gas_elements, num_oil_elements, water, current = \
        get_blowout()
    
    # Create the blowout.Blowout object
    spill = blowout.Blowout(z0, d0, substance, q_oil, gor, x0, y0, u0, phi_0, 
                            theta_0, num_gas_elements, num_oil_elements, 
                            water, current)
    
    # Check the object attributes set by the __init__() method
    check_attributes(z0, d0, substance, q_oil, gor, x0, y0, u0, phi_0, 
                     theta_0, num_gas_elements, num_oil_elements, 
                     water, current, spill)
    
    # Check the attributes not accessible to the user
    assert spill.new_oil == False
    assert spill.Sj == 0.
    assert spill.cj == 1.
    assert spill.tracers[0] == 'tracer'
    assert len(spill.disp_phases) == num_gas_elements + num_oil_elements
    assert spill.track == True
    assert spill.dt_max == 5. * 3600.
    assert spill.sd_max == 3. * z0 / d0
    assert spill.update == True
    
    # Check the CTD data
    T, S, P, ua, va = spill.profile.get_values(z0, ['temperature', 
                      'salinity', 'pressure', 'ua', 'va'])
    assert_approx_equal(spill.T0, T, significant=6)
    assert_approx_equal(spill.S0, S, significant=6)
    assert_approx_equal(spill.P0, P, significant=6)
    return spill
    assert_approx_equal(T, 286.45, significant=6)
    assert_approx_equal(S, 35.03, significant=6)
    assert_approx_equal(P, 1107655.378995259, significant=6)
    assert_approx_equal(ua, 0.09, significant=6)
    assert_approx_equal(va, 0., significant=6)
    
    # Check the bubble and droplet sizes
    de_gas = np.array([0.00367319, 0.00421546, 0.0048378 , 0.00555201, 
       0.00637166, 0.00731231, 0.00839184, 0.00963073, 0.01105253, 
       0.01268423])
    vf_gas = np.array([0.01545088, 0.0432876 , 0.09350044, 0.15570546, 
        0.19990978, 0.19788106, 0.15101303, 0.08885147, 0.04030462, 
        0.01409565])
    de_oil = np.array([0.00044767, 0.00063414, 0.00089826, 0.00127239, 
        0.00180236, 0.00255306, 0.00361644, 0.00512273, 0.0072564 , 
        0.01027876])
    vf_oil = np.array([0.00876514, 0.01619931, 0.02961302, 0.05303846, 
        0.09143938, 0.14684062, 0.20676085, 0.22874507, 0.16382356, 
        0.05477458])
    assert_array_almost_equal(spill.d_gas, de_gas, decimal=6)
    assert_array_almost_equal(spill.vf_gas, vf_gas, decimal=6)
    assert_array_almost_equal(spill.d_liq, de_oil, decimal=6)
    assert_array_almost_equal(spill.vf_liq, vf_oil, decimal=6)
    
    # Check the mass fluxes of each of the particles in the disp_phases
    # particle list
    m0 = np.array([5.289671808056377e-07, 7.995318667820805e-07, 
        1.2084893528298558e-06, 1.8266270258633492e-06,
        2.760939749945933e-06, 4.173149852104387e-06, 6.307700009918694e-06,
        9.534064393845064e-06, 1.4410701796700701e-05,
        2.1781720543811073e-05, 4.085231065881823e-08,
        1.1611175556114503e-07, 3.300165783053678e-07, 9.379837677075682e-07,
        2.665967731077995e-06, 7.5772995096915136e-06,
        2.1536445167832175e-05, 6.121157938574416e-05,
        0.00017397752608186881, 0.0004944845384698018])
    
    for i in range(len(m0)):
        assert_approx_equal(np.sum(spill.disp_phases[i].m), m0[i],
        significant=6)