Environmental Processes Analysis

aguaclara.research.environmental_processes_analysis.invpH(pH)[source]

Calculate inverse pH, i.e. hydronium ion concentration, given pH.

Parameters:

pH (float) – pH to be inverted

Returns:

The inverse pH or hydronium ion concentration (in moles per liter)

Return type:

float

Examples:

>>> from aguaclara.research.environmental_processes_analysis import invpH
>>> invpH(10)
<Quantity(1e-10, 'mole / liter')>
aguaclara.research.environmental_processes_analysis.alpha0_carbonate(pH)[source]

Calculate the fraction of total carbonates in carbonic acid form (H2CO3)

Parameters:

pH (float) – pH of the system

Returns:

Fraction of carbonates in carbonic acid form (H2CO3)

Return type:

float

Examples:

>>> from aguaclara.research.environmental_processes_analysis import alpha0_carbonate
>>> round(alpha0_carbonate(10), 7)
<Quantity(0.00015, 'dimensionless')>
aguaclara.research.environmental_processes_analysis.alpha1_carbonate(pH)[source]

Calculate the fraction of total carbonates in bicarbonate form (HCO3-)

Parameters:

pH (float) – pH of the system

Returns:

Fraction of carbonates in bicarbonate form (HCO3-)

Return type:

float

Examples:

>>> from aguaclara.research.environmental_processes_analysis import alpha1_carbonate
>>> round(alpha1_carbonate(10), 7)
<Quantity(0.639969, 'dimensionless')>
aguaclara.research.environmental_processes_analysis.alpha2_carbonate(pH)[source]

Calculate the fraction of total carbonates in carbonate form (CO3-2)

Parameters:

pH (float) – pH of the system

Returns:

Fraction of carbonates in carbonate form (CO3-2)

Return type:

float

Examples:

>>> from aguaclara.research.environmental_processes_analysis import alpha2_carbonate
>>> round(alpha2_carbonate(10), 7)
<Quantity(0.359881, 'dimensionless')>
aguaclara.research.environmental_processes_analysis.ANC_closed(pH, total_carbonates)[source]

Calculate the acid neutralizing capacity (ANC) under a closed system in which no carbonates are exchanged with the atmosphere during the experiment. Based on pH and total carbonates in the system.

Parameters:
  • pH (float) – pH of the system

  • total_carbonates (float) – Total carbonate concentration in the system (mole/L)

Returns:

The acid neutralizing capacity of the closed system (eq/L)

Return type:

float

Examples:

>>> from aguaclara.research.environmental_processes_analysis import ANC_closed
>>> from aguaclara.core.units import u
>>> round(ANC_closed(10, 1*u.mol/u.L), 7)
<Quantity(1.359831, 'equivalent / liter')>
aguaclara.research.environmental_processes_analysis.ANC_open(pH)[source]

Calculate the acid neutralizing capacity (ANC) calculated under an open system based on pH.

Parameters:

pH (float) – pH of the system

Returns:

The acid neutralizing capacity of the closed system (eq/L)

Return type:

float

Examples:

>>> from aguaclara.research.environmental_processes_analysis import ANC_open
>>> round(ANC_open(10), 7)
<Quantity(0.0907346, 'equivalent / liter')>
aguaclara.research.environmental_processes_analysis.aeration_data(DO_column, dirpath)[source]

Extract the data from folder containing tab delimited files of aeration data. The file must be the original tab delimited file. All text strings below the header must be removed from these files. The file names must be the air flow rates with units of micromoles/s. An example file name would be “300.xls” where 300 is the flow rate in micromoles/s. The function opens a file dialog for the user to select the directory containing the data.

Parameters:
  • DO_column – Index of the column that contains the dissolved oxygen concentration data.

  • dirpath (string) – Path to the directory containing aeration data you want to analyze

Returns:

collection of

  • filepaths (string list) - All file paths in the directory sorted by flow rate

  • airflows (numpy.array) - Sorted array of air flow rates with units of micromole/s

  • DO_data (numpy.array list) - Sorted list of Numpy arrays. Thus each of the numpy data arrays can have different lengths to accommodate short and long experiments

  • time_data (numpy.array list) - Sorted list of Numpy arrays containing the times with units of seconds

aguaclara.research.environmental_processes_analysis.O2_sat(P_air, temp)[source]

Calculate saturaed oxygen concentration in mg/L for 278 K < T < 318 K

Parameters:
  • P_air (float) – Air pressure with appropriate units

  • temp (float) – Water temperature with appropriate units

Returns:

Saturated oxygen concentration in mg/L

Return type:

float

Examples:

>>> from aguaclara.research.environmental_processes_analysis import O2_sat
>>> from aguaclara.core.units import u
>>> round(O2_sat(1*u.atm , 300*u.kelvin), 7)
<Quantity(8.0931572, 'milligram / liter')>
aguaclara.research.environmental_processes_analysis.Gran(data_file_path)[source]

Extract the data from a ProCoDA Gran plot file. The file must be the original tab delimited file.

Parameters:

data_file_path – The path to the file. If the file is in the working directory, then the file name is sufficient.

Returns:

collection of

  • V_titrant (float) - Volume of titrant in mL

  • ph_data (numpy.array) - pH of the sample

  • V_sample (float) - Volume of the original sample that was titrated in mL

  • Normality_titrant (float) - Normality of the acid used to titrate the sample in mole/L

  • V_equivalent (float) - Volume of acid required to consume all of the ANC in mL

  • ANC (float) - Acid Neutralizing Capacity of the sample in mole/L

aguaclara.research.environmental_processes_analysis.CMFR(t, C_initial, C_influent)[source]

Calculate the effluent concentration of a conversative (non-reacting) material with continuous input to a completely mixed flow reactor.

Note: time t=0 is the time at which the material starts to flow into the reactor.

Parameters:
  • C_initial (float) – The concentration in the CMFR at time t=0.

  • C_influent (float) – The concentration entering the CMFR.

  • t (float or numpy.array) – The time(s) at which to calculate the effluent concentration. Time can be made dimensionless by dividing by the residence time of the CMFR.

Returns:

Effluent concentration

Return type:

float

Examples:

>>> from aguaclara.research.environmental_processes_analysis import CMFR
>>> from aguaclara.core.units import u
>>> round(CMFR(0.1, 0*u.mg/u.L, 10*u.mg/u.L), 7)
<Quantity(0.9516258, 'milligram / liter')>
>>> round(CMFR(0.9, 5*u.mg/u.L, 10*u.mg/u.L), 7)
<Quantity(7.9671517, 'milligram / liter')>
aguaclara.research.environmental_processes_analysis.E_CMFR_N(t, N)[source]

Calculate a dimensionless measure of the output tracer concentration from a spike input to a series of completely mixed flow reactors.

Parameters:
  • t (float or numpy.array) – The time(s) at which to calculate the effluent concentration. Time can be made dimensionless by dividing by the residence time of the CMFR.

  • N (int) – The number of completely mixed flow reactors (CMFRS) in series. Must be greater than 1.

Returns:

Dimensionless measure of the output tracer concentration (concentration * volume of 1 CMFR) / (mass of tracer)

Return type:

float

Examples:

>>> from aguaclara.research.environmental_processes_analysis import E_CMFR_N
>>> round(E_CMFR_N(0.5, 3), 7)
0.7530643
>>> round(E_CMFR_N(0.1, 1), 7)
0.9048374
aguaclara.research.environmental_processes_analysis.E_Advective_Dispersion(t, Pe)[source]

Calculate a dimensionless measure of the output tracer concentration from a spike input to reactor with advection and dispersion.

Parameters:
  • t (float or numpy.array) – The time(s) at which to calculate the effluent concentration. Time can be made dimensionless by dividing by the residence time of the CMFR.

  • Pe (float) – The ratio of advection to dispersion ((mean fluid velocity)/(Dispersion*flow path length))

Returns:

dimensionless measure of the output tracer concentration (concentration * volume of reactor) / (mass of tracer)

Return type:

float

Examples:

>>> from aguaclara.research.environmental_processes_analysis import E_Advective_Dispersion
>>> round(E_Advective_Dispersion(0.5, 5), 7)
0.4774864
aguaclara.research.environmental_processes_analysis.Tracer_CMFR_N(t_seconds, t_bar, C_bar, N)[source]

Used by Solver_CMFR_N. All inputs and outputs are unitless. This is The model function, f(x, …). It takes the independent variable as the first argument and the parameters to fit as separate remaining arguments.

Parameters:
  • t_seconds (float list) – List of times

  • t_bar (float) – Average time spent in the reactor

  • C_bar (float) – Average concentration (mass of tracer)/(volume of the reactor)

  • N (int) – Number of completely mixed flow reactors (CMFRs) in series, must be greater than 1

Returns:

The model concentration as a function of time

Return type:

float list

Examples:

>>> from aguaclara.research.environmental_processes_analysis import Tracer_CMFR_N
>>> from aguaclara.core.units import u
>>> Tracer_CMFR_N([1, 2, 3, 4, 5]*u.s, 5*u.s, 10*u.mg/u.L, 3)
<Quantity([2.96358283 6.50579498 8.03352597 7.83803116 6.72125423], 'milligram / liter')>
aguaclara.research.environmental_processes_analysis.Solver_CMFR_N(t_data, C_data, theta_guess, C_bar_guess)[source]

Use non-linear least squares to fit the function Tracer_CMFR_N(t_seconds, t_bar, C_bar, N) to reactor data.

Parameters:
  • t_data (float list) – Array of times with units

  • C_data (float list) – Array of tracer concentration data with units

  • theta_guess (float) – Estimate of time spent in one CMFR with units.

  • C_bar_guess (float) – Estimate of average concentration with units ((mass of tracer)/(volume of one CMFR))

Returns:

tuple of

  • theta (float)- Residence time in seconds

  • C_bar (float) - Average concentration with same units as C_bar_guess

  • N (float)- Number of CMFRS in series that best fit the data

aguaclara.research.environmental_processes_analysis.Tracer_AD_Pe(t_seconds, t_bar, C_bar, Pe)[source]

Used by Solver_AD_Pe. All inputs and outputs are unitless. This is the model function, f(x, …). It takes the independent variable as the first argument and the parameters to fit as separate remaining arguments.

Parameters:
  • t_seconds (float list) – List of times

  • t_bar (float) – Average time spent in the reactor

  • C_bar (float) – Average concentration ((mass of tracer)/(volume of the reactor))

  • Pe (float) – The Peclet number for the reactor.

Returns:

The model concentration as a function of time

Return type:

float list

Examples:

>>> from aguaclara.research.environmental_processes_analysis import Tracer_AD_Pe
>>> from aguaclara.core.units import u
>>> Tracer_AD_Pe([1, 2, 3, 4, 5]*u.s, 5*u.s, 10*u.mg/u.L, 5)
<Quantity([0.25833732 3.23793989 5.8349833  6.62508831 6.30783131], 'milligram / liter')>
aguaclara.research.environmental_processes_analysis.Solver_AD_Pe(t_data, C_data, theta_guess, C_bar_guess)[source]

Use non-linear least squares to fit the function Tracer_AD_Pe(t_seconds, t_bar, C_bar, Pe) to reactor data.

Parameters:
  • t_data (float list) – Array of times with units

  • C_data (float list) – Array of tracer concentration data with units

  • theta_guess (float) – Estimate of time spent in one CMFR with units.

  • C_bar_guess (float) – Estimate of average concentration with units ((mass of tracer)/(volume of one CMFR))

Returns:

tuple of

  • theta (float)- Residence time in seconds

  • C_bar (float) - Average concentration with same units as C_bar_guess

  • Pe (float) - Peclet number that best fits the data