Skip to content
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

Change CSTR model to support variable porosity #245

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

AntoniaBerger
Copy link
Collaborator

@AntoniaBerger AntoniaBerger commented Jul 11, 2024

Fixes #249 and #211
As per discussion in #211, we need to make porosity variable for the CSTR.

TODO

  • Create new unit operation CSTRVarPor based on the CSTR unit operation. This is described in the dev guide; please also leave a comment or make changes to the guide.
  • Adapt the interface: Change POROSITY to CONST_SOLID_VOLUME, which will be the constant solid volume of the tank. Porosity will be computed from that and not be exposed to the user anymore.
  • Refactor the residual and Jacobian according to the new equations
  • testing:
    • new and old CSTR yield same result for constant volume simulations (test for simulations with/without binding, reaction)
    • adjust CSTR tests
    • Fix tests: three tests are failing, but they run on master (one of them only runs on master after the extendData function is fixed as done in this PR here)

@jbreue16 jbreue16 added unit operation model good first issue Good starting point for newcomers, easy to fix labels Jul 11, 2024
@schmoelder
Copy link
Contributor

* [ ]  Adapt the interface: Change `POROSITY` to `CONST_SOLID_VOLUME`, which will be the constant solid volume of the tank. Porosity will be computed from that and not be exposed to the user anymore.

As discussed yesterday, for downward compatibility, I would suggest exposing both, where CONST_SOLID_VOLUME takes precedence. I.e. when only POROSITY is given, take that value and compute CONST_SOLID_VOLUME from it. If both are given, ignore POROSITY.

@jbreue16
Copy link
Contributor

jbreue16 commented Jul 11, 2024

Maybe we want a breaking change since this is a completely new unit/model? It might actually make sense to force users to acknowledge that the model has changed.

Anyways, we should probably first decide if we are going to keep the old CSTR, because if yes then the discussion is obsolete.

If we want to expose porosity again, it would probably also make more sense to call it INIT_POROSITY here.

UPDATE:
We have decided to make changes to the interface but support the old interface (undocumented) and print warnings that the model has changed when the old interface is being used

@jbreue16 jbreue16 changed the title Feature/cstr variable porosity Add a CSTR with variable porosity Jul 11, 2024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this file should not be added to master and we should also not add them to a PR branch so that we dont mess it up later.

const double sVolume = paramProvider.exists("CONST_SOLID_VOLUME");
const double initVolume = paramProvider.getDouble("INIT_VOLUME");

if (sVolume != initVolume / eps - initVolume)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an exact floating point comparison. Due to round-off and / or representation errors (e.g., 0.3 cannot be represented exactly), it may not work. Allow some slack by introducing relative and / or absolute tolerance: https://codingnest.com/the-little-things-comparing-floating-point-numbers/

@jbreue16
Copy link
Contributor

Ive rebased, deleted the old CSTR and added backwards compatibility with the old interface with warnings.

I dont think we need the porosity as an output from CADET-Core since this is already given by the liquid volume .. that could be considered in a frontend like cadet-process or just leave it to the user.

The code still needs some clean up (e.g. change the descriptive comments to the new model) and maybe some changes for the consistent initialization.

@jbreue16 jbreue16 force-pushed the feature/CSTR_variable_porosity branch 4 times, most recently from a57704d to 2b470fb Compare August 14, 2024 13:05
@jbreue16 jbreue16 added this to the v5.0.0 "CADET-Core" milestone Aug 20, 2024
@jbreue16 jbreue16 force-pushed the feature/CSTR_variable_porosity branch from 697064a to 438ca75 Compare August 28, 2024 11:42
In the previous implementation, the CSTR supported variable total volume
with constant porosity. Now, only the liquid volume is variable but the
solid volume is fixed. Thus, the porosity is also variable.

* Changed CSTR implementation
* Adapted tests to repsoduce previous test cases
* Updated documentation

Co-authored-by: Antonia Berger <[email protected]>
@jbreue16 jbreue16 force-pushed the feature/CSTR_variable_porosity branch from 438ca75 to 4920f2f Compare September 2, 2024 15:24
@jbreue16 jbreue16 changed the title Add a CSTR with variable porosity Change CSTR model to support variable porosity Sep 2, 2024
@jbreue16 jbreue16 merged commit 1572ca6 into master Sep 3, 2024
4 checks passed
@jbreue16 jbreue16 deleted the feature/CSTR_variable_porosity branch September 3, 2024 08:11
@github-actions github-actions bot locked and limited conversation to collaborators Sep 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dev-call good first issue Good starting point for newcomers, easy to fix unit operation model
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Failing Test for CSTR
4 participants