Open sashahafner opened 5 months ago
We need total filter mass of "compound". Looks to me like you should do just before returning model results (around L 240) with something like this:
np.sum(mcgt, 0) + np.sum(mclt, 0)
The second argument in Numpy sum() is the array "axis" (dimension).
Here it is the first one in the mc*t
array, which means we get the sum over all the positions, but separately for each time.
I have tried to implement the line you are suggesting, and it gives a similar graph to mine, just coded a lot more elegantly. Nice. Next step is to plot the total mass of SH- in equilibrium with H2S in the liquid phase. I have tried in L237 in Mod_Funcs, but I am not sure if I have used the parameter Alpha0 correctly, or if it needs to be eg. concentration based, mole based ect.
Forgot to tag @sashahafner - how do you feel about this line of code?
mctot=np.sum(mcgt,0)+np.sum(mclt,0) #total mass of H2S in the entire column as a function of time.
mtot=mctot+(1-alpha0)*np.array(np.sum(mclt,0)) # mass of both H2S and SH- in the entire column as a function of time.
I'll check now. I got an update even without tagging, I think because I originally opened the issue.
@AnneMortensen it looks like you are editing the version in /tric-fil-mod/applications/04_Mass as a function of time and position/
.
We want to avoid multiple versions of the model, unless necessary.
Better to just edit /tric-fil-mod/mod_funcs.py
directly.
Remember we can also "undo" changes because we are using Git for version control.
This looks good to me: https://github.com/AU-BCE-EE/tric-fil-mod/blob/cda6aade74df7fc42f992cb09cbc7f7ae2f214f5/applications/04_Mass%20as%20a%20function%20of%20time%20and%20position/Mod_funcs.py#L236
But remember to use spaces!
mctot = np.sum(mcgt,0) + np.sum(mclt,0)
So this is total mass of the "compound" (that is what c
is for in variable names) in the column over time.
That is in g (grams), right?
In your case, with H2S in the gas phase, mctot
would include HS- as well.
This is because of the way we made the model, using Daw
with the ionization fraction alpha0
rolled into it.
# Ionization fraction
alpha0 = 1 / (1 + 10**(pH - pKa))
Daw = alpha0 * Kaw
You should verify this with equilibrium calculations though (I think you already have actually).
Anyway, L 237 does not make sense because of this.
mtot=mctot+(1-alpha0)*np.array(np.sum(mclt,0)) # mass of both H2S and SH- in the entire column as a function of time.
You should be all set with L 236.
By the way, if you ever want those "permalinks" to refer to a particular location in a particular version of a file (commit), click on here when viewing a file on github.com:
Okay, thank you for the feedback. 1) I think I might need some help as to how to get all my files to refer to the same version of the model. I think I found a way to detach from that when exploring the ways of the model back in august and has been working on different files since then. Also, (as you mentioned) my general workflow is different from yours regarding the experimental data and csv files, so I also need to get that aligned, which might take some time. As it is now, I have made all the data treatment into functions (calibration_func and DT_func), so that it is easier to do the data treatment separately, but I dont know what the next step would be. 2) I will erase L237, I had a feeling I had misunderstood something (and I probably need to brush up on the definitions of Daw and Kaw anyways).
- I think I might need some help as to how to get all my files to refer to the same version of the model. I think I found a way to detach from that when exploring the ways of the model back in august and has been working on different files since then.
I think this is the easiest way to do it:
import shutil
shutil.copy('../../mod_funcs.py', '.')
from mod_funcs import tfmod
The copy
function from shutil puts a copy of the file in your working directory ('.'
).
You just have to find the right location to copy from.
If you are here: tric-fil-mod/applications/04_Mass as a function of time and position/
and want mod_funcs.py
in tric-fil-mod
you need shutil.copy('../../mod_funcs.py', '.')
, with 2 sets of ../
just like above.
The ../
lets you specify relative paths (instead of absolute path).
See https://github.com/sashahafner/pystupid/#loading-function-definitions-modules for a bit more discussion on this issue of loading a function from a file not in the working directory.
- Also, (as you mentioned) my general workflow is different from yours regarding the experimental data and csv files, so I also need to get that aligned, which might take some time. As it is now, I have made all the data treatment into functions (calibration_func and DT_func), so that it is easier to do the data treatment separately, but I dont know what the next step would be.
It is great to use functions for data processing but in general the processed data should be saved as a csv file that you can then simply read in the next steps. Think about what steps are necessary for a given task. If you are working on model evaluation you shouldn't need to (re)process the raw measurement data every time.
@AnneMortensen is working on this.