-
Notifications
You must be signed in to change notification settings - Fork 1
Update Contaminant Structure Model #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Update Contaminant Structure Model #10
Conversation
|
I fixed the segmentation fault my removing the line which set the constants variable |
|
I've fixed a couple of namelist errors in the latest commit. I'm now getting I haven't started digging into this yet and have to give up for today, but it looks to be something to do with the emissions data parsing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you've copied the constants defaults from DefaultsModule to here. Is this a work-in-progress, as I don't think this new file is used anywhere yet? I think it's probably a good idea to separate config and constants defaults, so I'm happy to have these in separate files!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new module is super! 🙂 However, it would be good to add some comments describing each of the procedures and what the code within them is doing 😉
| end if | ||
| call sum_result%add(this) | ||
| call sum_result%add(other) | ||
| sum_result%rho_contaminant = this%rho_contaminant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to check my understanding of this: When you add two contaminants, does this work such that the properties (rho, k_diss etc) stay as the first contaminant in the addition. E.g. for two contaminants A and B, then A + B would result in a contaminant with the properties of A? I think that's fine, but it does make it non-commutative and so we definitely want to document this clearly somewhere! I can imagine my future self being caught out by this 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more a note for the future: A lot of the stuff in this module is specific to particulate contaminants, such as heteroaggregation, so we might want to think about creating a ParticulateContaminant module that extends from this. Other stuff like "pristine", "transformed" and "dissolved" might not be relevant to all contaminants either. I think it's okay to leave this stuff in here for the moment, but this is something to bear in mind when we start adding different contaminants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P.S. This will raise a tonne of difficulties (which is why I suggest not tackling it straight away!). For example, if we go with a ParticulateContaminant module that extends from this module, then we'll probably end up which a rank mismatch for the concentration property c: In this module, c will probably want to be a scalar, whilst in the ParticulateContaminant module, it will at least need a particle size dimension (and then for nanomaterials, it will be the full 3-dimension array that we've got here). There are ways around this, but we need to do a bit of thinking about what would work best.
src/ContaminantModule.f90
Outdated
|
|
||
| contains | ||
|
|
||
| ! Local function to replace str from UtilModule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand why this is needed here (or if it is used). Would using the version from the UtilModule cause some kind of dependency loop?
src/Reactor/ReactorModule.f90
Outdated
| ! Calculate k_att for water/estuary | ||
| if (.not. allocated(me%k_att)) then | ||
| allocate(me%k_att(C%nContaminantSizeClasses)) | ||
| me%k_att = me%contaminant%calculateAttachmentRate(me%T_water, DATASET%soilDefaultPorosity, & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another note for the future: Following on from my comment on ContaminantModule about whether a generic contaminant should have potentially contaminant- (or particulate-) specific processes like attachment, we might want to think about moving process rate constant calculation stuff like this to specific contaminant classes. Again, not something to tackle now, but just bear in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Yet) another option would be to have Reactors specific to different contaminants. In fact, I think perhaps that makes more sense. Either way, it's great to see contaminant-specific code like this ported away from compartments (reaches etc) and into here!
src/Soil/SoilLayerModule.f90
Outdated
| end if | ||
| class(SoilLayer) :: me | ||
| real(dp) :: T_water_t | ||
| ! Handled by update_soil in ReactorModule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome 🙂 Can this procedure be deleted now?
test.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this file be .gitignored?
| subroutine initDataOutput(me, env) | ||
| class(DataOutput) :: me | ||
| subroutine initDataOutput(this, env) | ||
| class(DataOutput) :: this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's wrong with me?!? 😉 Joking aside, we should probably make this standard across the code. There's a bit of history here: We went with me originally as that was Steve's preference (and I think it comes from VB). I would have at that point in time gone with this instead, mainly because I was writing a lot of Java(Script) and PHP back then. On reflection, I'm wondering whether self is more appropriate for Fortran, based loosely on the fact that Fortran is definitely not C(++), and that Python draws a lot on Fortran roots. Maybe we should put it to vote?! 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a similar argument to be had about whether we use camelCase or snake_case. Again, I went with camelCase originally because I was writing a lot of PHP at the time, but I've come to dislike camelCase (I think it's less readable) and it really doesn't make sense to use something that relies on case sensitivity when Fortran is case insensitive! Obviously changing this would require a full refactor and we probably shouldn't dive into that right now!
src/Data/DataInputModule.f90
Outdated
| me%resuspensionBeta(x,y) = me%waterResuspensionBeta | ||
| end if | ||
| call LOGR%toFile(errors=[ErrorInstance( & | ||
| message="Missing "//trim(varname)//"; trying old variable names", & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - I like the backwards compatibility 🤩
de97d41 to
b6dadf2
Compare
|
The latest error is being caused by This is where they used to be: nanofase/src/Data/DataInputModule.f90 Lines 433 to 435 in 5a52deb
|
| !---------------------- | ||
| ! BASIC TIME SERIES | ||
| !---------------------- | ||
| if (me%nc%hasVariable('quickflow')) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if clause effectively makes quickflow (and runoff below) optional, with a default of 0. I think this is okay, but the docs need updating to reflect this as well (this file: https://github.com/NERC-CEH/nanofase/blob/develop/docs/users/parameters/met-hydro-parameters.csv)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Same for precip)
|
Mostly notes to myself - I made a very brief start on debugging differences in model outputs but will pick this up again after the weekend. I'm doing it using notebooks (well, a notebook so far) in this repo: https://github.com/samharrison7/fase-output-testing. I've only looked at non-contaminant vars (e.g. SPM concentrations). Findings so far:
|
|
I've made a bit of progress debugging. So far I've found that:
I'll try and dig a bit deeper tomorrow! |
|
Latest progress: Resuspension parameters are being read in correctly the resuspension rates ( In the new model, In the old model, the first size class varies, e.g.: I have to leave this now, but I've pushed my changes in the latest commit. |


No description provided.