-
Notifications
You must be signed in to change notification settings - Fork 27
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
Reverse flow not working when using dynamic flow rates #96
Comments
After some debugging, @Immudzen and I found the issue: https://github.com/modsim/CADET/blob/bc099eadf0f58e591e40f8e6ce093d8494a583ba/src/libcadet/model/ModelSystemImpl-Residual.cpp#L499 To update the direction, we would need to call the notifyDiscontinuousSectionTransition() of the ConvectionDispersionOperator. However, we do not have access to secIdx inside the residual function. To solve this, we could - on section transition - store the current direction in the column object and include the direction directly in the calculation of the velocity. |
Sorry, I still don't understand. Please elaborate some more. Why is there no discontinuous section transition? |
The |
I already have an idea how to fix it; I will create a PR in case this is going somewhere. ^^ |
Ah, I see. The I haven't given it much thought, but what about preserving the sign in void ConvectionDispersionOperatorBase::setFlowRates(const active& in, const active& out, const active& colPorosity) CADET_NOEXCEPT
{
// If we have do not have cross section area, interstitial velocity is specified explicitly in the model
if (_crossSection <= 0.0)
return;
if (_curVelocity < 0.0)
_curVelocity = -in / (_crossSection * colPorosity);
else
_curVelocity = in / (_crossSection * colPorosity);
} |
I guess that should also work, I will give it a try! Otherwise I would have suggested to simply add void ConvectionDispersionOperatorBase::setFlowRates(const active& in, const active& out, const active& colPorosity) CADET_NOEXCEPT
{
// If we have cross section area, interstitial velocity is given by network flow rates
if (_crossSection > 0.0)
_curVelocity = _dir * in / (_crossSection * colPorosity);
} and modify the notifyDiscontinuousSectionTransition() method correspondingly, s.t. it flips sign if _dir_old != _dir. Semantically it would also separate velocity (which, except for the parameter that is read) would then always mean the interstitial velocity, and direction, which would always mean its sign. |
Both solutions are fine with me 😄 |
bool ConvectionDispersionOperatorBase::notifyDiscontinuousSectionTransition(double t, unsigned int secIdx)
{
// If we don't have cross section area, velocity is given by parameter
double _dir_old = _dir;
if (_crossSection <= 0.0)
_dir = getSectionDependentScalar(_velocity, secIdx);
else if (!_velocity.empty())
{
// We have both cross section area and interstitial flow rate
// _curVelocity has already been set to the network flow rate in setFlowRates()
// the direction of the flow (i.e., sign of _curVelocity) is given by _velocity
_dir = static_cast<double>(getSectionDependentScalar(_velocity, secIdx));
if (_dir_old * static_cast<double>(_dir) < 0.0)
_curVelocity *= -1.0;
}
return (_dir_old * static_cast<double>(_dir) < 0.0);
} |
If dynamic flow rates are enabled in the connections, the column velocity (which used to determine the flow direction if the cross section area is also provided) is no longer taken into account.
Here are some examples:
dyn_flow_rate_examples.zip
The text was updated successfully, but these errors were encountered: