adios_db.computation package

Utilities for doing computation with the oil data

For the most part, what these do is extract the actual data in an Oil object with specified units, etc.

There are also some facilities for working with the data, such as interpolating, etc.

Submodules

adios_db.computation.estimations module

Code for estimating various properties that aren’t in a oil record.

These can be used to generate complete oil specifications for modeling, etc.

Note: there is code in here to make various estimations of

SARA fractionations – be warned, these are of unceratain use, and not very accurate

adios_db.computation.estimations.aromatic_densities(boiling_points)
adios_db.computation.estimations.aromatic_mol_wt(boiling_point)
Source: Dr. M. R. Riazi,

Characterization and Properties of Petroleum Fractions eq. 2.48 and table 2.6

Note: for this to actually work in every case, we need to limit

our temperature to: - T_i < 1015.0 - T_i > 1015.0 - exp(6.911) (roughly about == 11.76)

adios_db.computation.estimations.aromatics_fraction(f_res, f_asph, f_sat)
adios_db.computation.estimations.asphaltene_densities(boiling_points)
adios_db.computation.estimations.asphaltene_fraction(density, viscosity, f_other=0.0)
adios_db.computation.estimations.asphaltene_mol_wt(boiling_points)

Source: Recommendation from Bill Lehr

adios_db.computation.estimations.cut_temps_from_api(api, N=5)
Source: Adios2 & Jones R. (1997),

A Simplified Pseudo-component Oil Evaporation Model, Proceedings of the 20th Arctic and Marine Oil Spill Program, Vancouver, CA, Vol. 1, pp. 43-62

Generate distillation cut temperatures from the oil’s API.

adios_db.computation.estimations.emul_water(density, viscosity)

This function computes two terms used in emulsification. Ymax is the maximum water fraction of a stable emulsion. Smax is the maximum surface area of the water droplets inside the emulsion. (from ADIOS2)

adios_db.computation.estimations.flash_point_from_api(api)
Source: Reference: Chang A., K. Pashakanti, and Y. Liu (2012),

Integrated Process Modeling and Optimization, Wiley Verlag.

adios_db.computation.estimations.flash_point_from_bp(temp_k)
Source: Reference: Chang A., K. Pashakanti, and Y. Liu (2012),

Integrated Process Modeling and Optimization, Wiley Verlag.

adios_db.computation.estimations.fmasses_flat_dist(f_res=0, f_asph=0, N=5)

Generate a flat distribution of N distillation cut fractional masses.

adios_db.computation.estimations.fmasses_from_cuts(f_evap_i)

Generate distillation cut fractional masses from the cumulative distillation fractions in the cut data.

adios_db.computation.estimations.oil_water_surface_tension_from_api(api)
adios_db.computation.estimations.pour_point_from_kvis(ref_kvis, ref_temp_k)

Source: Adios2

If we have an oil kinematic viscosity at a reference temperature, then we can estimate what its pour point might be.

adios_db.computation.estimations.resin_densities(boiling_points)
adios_db.computation.estimations.resin_fraction(density, viscosity, f_other=0.0)
adios_db.computation.estimations.resin_mol_wt(boiling_points)

Source: Recommendation from Bill Lehr

adios_db.computation.estimations.saturate_densities(boiling_points)
adios_db.computation.estimations.saturate_mass_fraction(fmass_i, temp_k, total_sat=None)

Source: Dr. Robert Jones, based on average of 51 Exxon oils This assumes we do not known the SARA totals for the oil

adios_db.computation.estimations.saturate_mol_wt(boiling_point)
Source: Dr. M. R. Riazi,

Characterization and Properties of Petroleum Fractions eq. 2.48 and table 2.6

Note: for this to actually work in every case, we need to limit

our temperature to: - T_i < 1070.0 - T_i > - T_i > 1070.0 - exp(6.98291) (roughly about == -8.06)

adios_db.computation.estimations.saturates_fraction(density, viscosity, f_other=0.0)
adios_db.computation.estimations.trial_densities(boiling_points, watson_factor)
Source: Dr. M. R. Riazi,

Characterization and Properties of Petroleum Fractions eq. 2.13 and table 9.6

Generate an initial estimate of volatile oil components based on boiling points and the Watson Characterization Factor. This is only good for estimating Aromatics & Saturates.

adios_db.computation.gnome_oil module

Code for making a “GnomeOil” from an Oil Object

See the PyGNOME code for more about GNOME’s requirements

NOTE: This make s JSON compatible Python structure from which to build a GnomeOil

adios_db.computation.gnome_oil.clamp(x, M, zeta=0.03)

We make use of a generalized logistic function or Richard’s curve to generate a linear function that is clamped at x == M. We make use of a zeta value to tune the parameters nu, resulting in a smooth transition as we cross the M boundary.

adios_db.computation.gnome_oil.component_densities(boiling_points)

estimate component densities from boiling point

adios_db.computation.gnome_oil.component_mass_fractions(oil)

estimate pseudocomponent mass fractions

adios_db.computation.gnome_oil.component_mol_wt(boiling_points)

estimate component molecular weight from boiling point

adios_db.computation.gnome_oil.component_temps(cut_temps, _N=10)

component temps from boiling point

adios_db.computation.gnome_oil.component_types(cut_temps, N=10)

set component SARA types

adios_db.computation.gnome_oil.estimate_pour_point(oil)

estimate pour point from kinematic viscosity

adios_db.computation.gnome_oil.get_empty_dict()

This provides an empty dictionary with everything that is needed to generate a GNOME Oil

adios_db.computation.gnome_oil.inert_fractions(oil, density=None, viscosity=None)

resins and asphaltenes from database or estimated if None

adios_db.computation.gnome_oil.make_gnome_oil(oil)

Make a dict that a GnomeOil can be built from

A GnomeOil needs:

“name, “# Physical properties “api, “pour_point, “solubility, # kg/m^3 “# emulsification properties “bullwinkle_fraction, “bullwinkle_time, “emulsion_water_fraction_max, “densities, “density_ref_temps, “density_weathering, “kvis, “kvis_ref_temps, “kvis_weathering, “# PCs: “mass_fraction, “boiling_point, “molecular_weight, “component_density, “sara_type, “adios_oil_id=None,

adios_db.computation.gnome_oil.normalized_cut_values(oil)
adios_db.computation.gnome_oil.normalized_cut_values_adios(oil)
adios_db.computation.gnome_oil.sara_totals(oil)

get SARA from database estimate if no data

adios_db.computation.physical_properties module

utilities for doing computation on the physical properties of an oil record

class adios_db.computation.physical_properties.Density(oil)

Bases: object

class to hold and do calculations on density

data is stored internally in standard units: temperature in Kelvin density in kg/m^3

at_temp(temp, unit='K')

density(s) at the provided temperature(s)

Parameters:
  • temp – scalar or sequence of temp in K

  • unit='K' – unit of temperature

densities will be returned as kg/m^3

initialize()

Initialize the expansion coefficient

For outside the measured range

class adios_db.computation.physical_properties.KinematicViscosity(oil_or_data, k_v2=None)

Bases: object

Class to hold and do calculations on kinematic viscosity

Data is stored internally in standard units: temperature in Kelvin viscosity in m^2/s

Viscosity as a function of temp is given by:

v = A exp(k_v2 / T)

DEFAULT_KV2 = 2100.0
at_temp(temp, kvis_units='m^2/s', temp_units='K')

Compute the kinematic viscosity of the oil as a function of temperature

Parameters:

temp_k – temperatures to compute at: can be scalar or array of values. Should be in Kelvin

viscosity as a function of temp is given by: v = A exp(k_v2 / T)

with constants determined from measured data

default_kvs = {'Crude Oil NOS': 2099.9999, 'Distillate Fuel Oil': 6200.0}
initialize()

viscosity as a function of temp is given by:

v = A exp(k_v2 / T)

The constants, A and k_v2 are determined from the viscosity data:

If only one data point, a default value for k_vs is used:

2100 K, based on analysis of data in the ADIOS database as of 2018

If two data points, the two constants are directly computed

If three or more, the constants are computed by a least squares fit.

adios_db.computation.physical_properties.bullwinkle_fraction(oil)
adios_db.computation.physical_properties.convert_dvisc_to_kvisc(dvisc, density)

convert dynamic viscosity to kinematic viscosity

Parameters:

density – an initialized Density object

dvisc is a table as returned from:

  • get_dynamic_viscosity_data

e.g. [(0.043, 275.15), (0.012, 286.15), (0.0054, 323.15)]

units: viscosity: Pa s or kg/(m s) (same thing)

density: kg/m^3

adios_db.computation.physical_properties.emul_water(oil)

This function computes two terms used in emulsification. Ymax is the maximum water fraction of a stable emulsion. Smax is the maximum surface area of the water droplets inside the emulsion. (from ADIOS2)

adios_db.computation.physical_properties.get_density_data(oil, units='kg/m^3', temp_units='K')

Return a table of density data:

list of (density, temp) pairs

Parameters:
  • oil – the oil object to get data from

  • units="kg/m^3" – units you want the density in

  • temp_units="K" – units you want the density in

adios_db.computation.physical_properties.get_distillation_cuts(oil, units='fraction', temp_units='K')

Return a table of distillation data:

list of (cut fraction, temp) pairs

Parameters:
  • oil – the oil object to get data from

  • units="fraction" – units you want the fraction in

  • temp_units="K" – units you want the temperature in

adios_db.computation.physical_properties.get_dynamic_viscosity_data(oil, units='Pas', temp_units='K', shear_rate=None)

Return a table of dynamic viscosity data:

list of (viscosity, temp) pairs

Parameters:
  • oil – the oil object to get data from

  • units="Pas" – units you want the viscosity in

  • temp_units="K" – units you want the temperature in

  • shear_rate (float or int) – what shear rate the data are for, in 1/s if None, the first shear rate found will be used, if there are more than one.

adios_db.computation.physical_properties.get_flash_point(oil)

Return oil’s FLash Point or None

adios_db.computation.physical_properties.get_frac_recovered(oil, units='fraction')

Return fraction recovered or None and whether fraction recovered is in the database T or F

Parameters:
  • oil – the oil object to get data from

  • units="fraction" – units you want the fraction in

adios_db.computation.physical_properties.get_interfacial_tension_seawater(oil, units='N/m', temp_units='K')

Return a table of interfacial tension data:

list of (interfacial tension, temp) pairs

Parameters:
  • oil – the oil object to get data from

  • units="N/m" – units you want the interfacial tension in

  • temp_units="K" – units you want the reference temperature in

adios_db.computation.physical_properties.get_interfacial_tension_water(oil, units='N/m', temp_units='K')

Return a table of interfacial tension data:

list of (interfacial tension, temp) pairs

Parameters:
  • oil – the oil object to get data from

  • units="N/m" – units you want the interfacial tension in

  • temp_units="K" – units you want the reference temperature in

adios_db.computation.physical_properties.get_kinematic_viscosity_data(oil, units='m^2/s', temp_units='K', shear_rate=None)

Return a table of kinematic viscosity data:

list of (viscosity, temp) pairs

Parameters:
  • oil – the oil object to get data from

  • units="m^2/s" – units you want the viscosity in

  • temp_units="K" – units you want the temperature in

  • shear_rate (float or int) – what shear rate the data are for, in 1/s if None, the first shear rate found will be used, if there are more than one.

adios_db.computation.physical_properties.get_pour_point(oil)

Return oil’s pour point or None

adios_db.computation.physical_properties.max_water_fraction_emulsion(oil)

This function looks for max water fraction in the database The value chosen from the database is the maximum water fraction of a stable emulsion.

adios_db.computation.utilities module

assorted utilities for querying an Oil object

adios_db.computation.utilities.get_evaporated_subsample(oil)

return the first evaporated sub_sample if there is one: