AU-BCE-EE / tric-fil-mod

A trickling filter model to simulate air treatment, written in Python
GNU General Public License v3.0
0 stars 0 forks source link

Dispersion? #16

Open sashahafner opened 1 year ago

sashahafner commented 1 year ago

I will try to add it this month.

sashahafner commented 1 year ago

Struggling with this. Probably just being sloppy. This does not work yet:

  # Derivatives
  # Set up empty arrays
  dmg = dml = g2l = np.zeros(nc)

  # Common term, mass transfer into liquid phase (g/s)
  #g/s  1/s    m3(t)     ----g/m3(g)-----
  g2l = Kga * vol_tot * (ccg - ccl * Daw) 

  # Gas phase derivatives (g/s)
  # No reaction in gas phase
  # cddiff = concentration double difference (g/m3)
  # cvec = array of cell concentrations with inlet air added
  # rxn = 0 for as phase
  cvec = np.insert(ccg, 0, cgin)
  advec = - v_g * np.diff(cvec)

  # Dispersion
  cdiff = np.insert(np.append(np.diff(ccg, n = 2), 0), 0, 0)
  disp = disp_gas * cdiff / dx**2

  dmg = advec - g2l - disp

I see this error:

/usr/lib/python3/dist-packages/numpy/lib/function_base.py:1292: RuntimeWarning: overflow encountered in subtract
  a = op(a[slice1], a[slice2])
/home/sasha/GitHub_repos/tric-fil-mod/demos/17_dispersion/mod_funcs.py:121: RuntimeWarning: invalid value encountered in subtract
  dmg = advec - g2l - disp
/home/sasha/GitHub_repos/tric-fil-mod/demos/17_dispersion/mod_funcs.py:125: RuntimeWarning: invalid value encountered in multiply
  rxn = k * mcl
 lsoda--  at t (=r1), too much accuracy requested  
       for precision of machine..  see tolsf (=r2) 
      in above,  r1 =  0.1092960888311D+01   r2 =                  NaN
/usr/lib/python3/dist-packages/scipy/integrate/_ode.py:1350: UserWarning: lsoda: Excess accuracy requested (tolerances too small).

Presumably the value of a derivative is too high.

sashahafner commented 1 year ago

Parked that code in a new dispersion branch. Will come back to it.

sashahafner commented 1 year ago

Maybe @AnneMortensen can help with this task later.