-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add Multi Channel Transport Model (MCT) #95
Conversation
8fe0d02
to
7a5de59
Compare
Where does the name |
I agree with giving it a descriptive name. That also makes it easier to use the name or if it appears in a presentation, paper etc. |
Oh yes, it's just a working title because @hannahlanzrath is still checking with her supervisor what to call it. |
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.
Do we need separate function for it or can we just read the parameter like any other model parameter?
agreed, but I just added the general framework and as soon as I have information from Hannah about the actual interface then I will made modifications accordingly. |
In my view, adding a specific configuration function to read the parameters of this particular model makes the tracibility of the current implementation a bit straight forward. Just my opinion. Else we can read them like the other parameters. |
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.
That will work as a first shot but is going to be inefficient.
I'd prefer setting the sparsity pattern based on the actual exchange matrix structure (i.e., only add non-zeros in the pattern for compartments that actually communicate).
To this end, setSparsityPattern()
can be called in configure()
instead of configureModelDiscretization()
.
f0d3248
to
af94b64
Compare
We fixed that by only adding the pattern only if the entry in the matrix is non-zero.
@jazib-hassan-juelich @jayghoshter yesterday, you had a look at the order of calling the various configure functions. Any comments on that? Other than that, we're still awaiting tests from @hannahlanzrath but I hope it works now. We also implemented the exchange matrix s.t. it also would work for multiple components. assuming e_{i,j,k} describes the transport of component k from compartment i to j, the matrix has the following form (assuming a 2 component system): @Immudzen also suggested we could take a similar approach to how we setup the connections, meaning that we only specify [compartment_from, compartment_to, component_index, exchange_rate]. |
8dc4028
to
74059fd
Compare
|
If I remember correctly, we first tried to implement the exchange matrix in the configure function, but then we faced the problem in the residualImpl Function in Line that the exchange matrix had no entries which caused the simulation to fail. Due to this issue we defined the exchange matrix configureModelDiscretization() so that when this function is called exhange matrix is already defined. |
Not much more to comment. As @jazib-hassan-juelich wrote,
I think the issue was that |
|
||
for (unsigned int comp = 0; comp < _nComp; ++comp) | ||
{ | ||
const ParamType exchange_orig_dest_comp = static_cast<ParamType>(_exchangeMatrix[rad_orig * _nRad * _nComp + rad_dest * _nComp + comp]); |
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 will always be active
. In fact, it doesn't really matter. So no need for this function to be a template. Just choose between double
and active
.
Well, then don't call it at this point 😛 It makes more sense to read the exchange matrix in |
_jacC.centered(offsetCur_orig, 0) += static_cast<double>(exchange_orig_dest_comp); | ||
_jacC.centered(offsetCur_orig, offsetCur_dest) -= static_cast<double>(exchange_orig_dest_comp); | ||
_jacC.centered(offsetCur_dest, 0) -= static_cast<double>(exchange_orig_dest_comp); | ||
_jacC.centered(offsetCur_dest, offsetCur_orig) += static_cast<double>(exchange_orig_dest_comp); |
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.
We have changes in two different residuals (is this correct? Could already be accounted for in _exchangeMatrix
). In each change, only one state vector item is involved. Hence, we should see two changes in the Jacobian:
d resCur_orig / d yCur_orig = exchange_orig_dest_comp
d resCur_dest / d yCur_orig = -exchange_orig_dest_comp
We also need to take into account that the second argument of centered()
refers to the offset on the main diagonal of the matrix. That is, centered(x,y)
refers to matrix item mat_{x, x+y}
.
This leads to the code
_jacC.centered(offsetCur_orig, 0) += static_cast<double>(exchange_orig_dest_comp);
_jacC.centered(offsetCur_dest, static_cast<int>(offsetCur_orig) - static_cast<int>(offsetCur_dest)) -= static_cast<double>(exchange_orig_dest_comp);
Since resCur_orig
corresponds to yCur_orig
, we get diagonal 0
. For the second, we need the offset from resCur_dest
to yCur_orig
. From our current position (diagonal 0
, equivalent to resCur_dest
), we go back to the origin (-offsetCur_dest
) and from there to yCur_orig
(+offsetCur_orig
). Note that we need to convert to int
because unsigned int
does not allow for negative offsets.
General remarks:
|
16f5947
to
3338c96
Compare
sorry, I made a mess while trying to rebase. I will clean up and force push. |
@hannahlanzrath has put some test cases on sciebo(?). If those work correctly, we can rebase and merge. |
3338c96
to
16f5947
Compare
We need to make sure to also implement the fix for dynamic flow rates provided in #101. |
16f5947
to
e2fb385
Compare
8f4e0d6
to
bc748c3
Compare
bc748c3
to
ccb59d2
Compare
Hi Hannah, sorry for the long silence. If we look at the to-dos, we're only missing a unit test. Maybe we can get this done next Friday during our Core-Dev Meeting. Other than that, we're good to go. |
Update on the Unittest Issue A Unittest file (test->MultiChannelTransportModel.cpp) was added, and a simple test case created, that compares the outlets of two seperate channels with the same configuration.
Also we rebased as a preparation to merge into the main branch |
4ebf612
to
e6a188e
Compare
What would be the right way to pull now to avoid merge conflicts and just get the current version? |
If you don't have any local changes, try the following:
|
Jan and I found out that the Jacobian tests fail for the GRM2D as well. The fowards/backwards tests do not work for any of the models, we even tested on a branch without MCT. Thus the tests not working likely has nothing to do with the implementation of the MCT but a general problem of the cadet-core. We will check the commits if we find a state in which these tests were still working. |
Sam added, that for the 2DGRM Algorithmic Differentiation is not working, so
|
Johannes and I noticed, that the Exchange Matrix is not only nchannel x nchannel but can be defined for every component, so
|
Ive fixed the MCT backwards flow and updated the tests: We should add a test against a reference solution. @hannahlanzrath I think its alright to use the LRM without porosity to generate one. Maybe @sleweke can generate an analytical one using CADET-semianalytic sometime. |
Heads up: Before merging, this branch would have to be rebased anyways, so we went ahead an rebased it now to get it to play nicely with the update build instructions. This will, however, break workflows for people using this branch with the old build instructions (I think). Therefore I haven't force pushed the rebased branch onto this branch but create a new one. Let's discuss in which order to merge these changes Wednesday in the office. |
a16136b
to
9bc140a
Compare
* Original implementation (Samuel Leweke) * Bug fixes (Jan Breuer, Johannes Schmoelder, Hannah Lanzrath) Co-authored-by: Jan Breuer <[email protected]> Co-authored-by: Johannes Schmoelder <[email protected]> Co-authored-by: Hannah Lanzrath <[email protected]>
Co-authored-by: Hannah Lanzrath <[email protected]>
90d214e
to
d0bb8e6
Compare
* Original implementation (Samuel Leweke) * Bug fixes (Jan Breuer, Johannes Schmoelder, Hannah Lanzrath) Co-authored-by: Jan Breuer <[email protected]> Co-authored-by: Johannes Schmoelder <[email protected]> Co-authored-by: Hannah Lanzrath <[email protected]>
Congrats! 🎉 |
thanks a lot for all your collective work on this guys, you're the coolest people 😎👌 |
This PR implements a modified 2D-GRM to model plant root systems as described here
To-do
https://github.com/modsim/CADET/blob/8fe0d0203a94242a0c51032704ab3585b14a1caf/src/libcadet/model/parts/TractorConvectionDispersionOperator.cpp#L1122