Skip to content

Conversation

@mollydougher
Copy link
Contributor

@mollydougher mollydougher commented Jul 14, 2025

Summary/Motivation:

This PR extends the mathematical model in diafiltration_two_salt.py to incorporate the multi-component partitioning behavior at the solution-membrane interfaces. Additionally, this PR adds the functionality to account for a fixed surface charge on the membrane, which is typically seen in nanofiltration membranes such as NF270.

Changes proposed in this PR:

  • Adds solute partition coefficients to the two-salt diafiltration model
  • Adds a non-zero fixed membrane charge to the two-salt diafiltration model
  • Adjusts the membrane solute flux equation(s) to account for the extensions to the mathematical model described above
  • Converts the diafiltration model from a mass-basis to a mole-basis
  • Implements analytical expressions for the derived convection and diffusion coefficients
  • Updates documentation

Reviewer's checklist / merge requirements:

  • The head branch (i.e. the "source" of the changes) is not the main branch on the PR author's fork
  • Documentation
  • Tests
  • Diagnostic tests for models

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the license terms described in the LICENSE.md file
    at the top level of this directory.

  2. I represent I am authorized to make the contributions and grant the license. If my employer has
    rights to intellectual property that includes these contributions, I represent that I have
    received permission to make contributions and grant the required license on behalf of that
    employer.

@mollydougher mollydougher self-assigned this Jul 14, 2025
@codecov
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

❌ Patch coverage is 93.22034% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.54%. Comparing base (027a8c8) to head (e901925).

Files with missing lines Patch % Lines
.../nanofiltration/diafiltration_solute_properties.py 71.42% 2 Missing ⚠️
.../nanofiltration/diafiltration_stream_properties.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #164      +/-   ##
==========================================
+ Coverage   85.83%   87.54%   +1.71%     
==========================================
  Files          73       73              
  Lines        9508     9558      +50     
  Branches     1266     1276      +10     
==========================================
+ Hits         8161     8368     +207     
+ Misses       1143      985     -158     
- Partials      204      205       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mollydougher mollydougher requested a review from bpaul4 August 12, 2025 17:32
Copy link
Contributor

@dallan-keylogic dallan-keylogic left a comment

Choose a reason for hiding this comment

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

Some comments.

"of the valid range for the diffusion coefficient approximations "
"(50-80 mM). The linearized approximation should be re-calculated."
)

Copy link
Contributor

Choose a reason for hiding this comment

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

There's an old and little-used API for validation like this: the model_check method on the unit model block. It would probably be good to implement these checks by implementing a model_check method on your unit model.

Copy link
Contributor Author

@mollydougher mollydougher Nov 26, 2025

Choose a reason for hiding this comment

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

I was able to implement the analytical version of the equations that used this model check. These equations are not limited to a valid concentration range. Thus, the need for this model_check and isn't needed anymore (at least for now). I will keep this in mind if/when we return to any concentration-limited surrogates.


Additionally, there are two required arguments, ``NFEx`` and ``NFEz``, to specfiy the desired number of finite elements across the width and thickness of the membrane, respectively.
There are two required arguments, ``NFE_module_length`` and ``NFE_membrane_thickness``, to specify the desired number of finite elements across the width and thickness of the membrane, respectively. There is one optional argument, ``charged_membrane``, which is a Boolean (default = ``True``) to specify if the membrane has a fixed surface charge.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the model structure change depending on whether the membrane has a fixed surface charge or is uncharged?

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like the big thing that changes is which set of parameters is loaded in. Instead of using a Bool here, consider using an Enum like is done in the heat exchanger. That allows you to naturally extend the system if you want to try, for example, a third level of charge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similarly, I think this comment can be moved to the back burner, as the analytical equations take the fixed membrane charge as an input and there are no longer different parameter sets to load in.

@mollydougher
Copy link
Contributor Author

@bpaul4 @dallan-keylogic This PR is ready for another round of reviews.

The codecov/patch test is now failing, with the uncovered file being diafiltration_flowsheet_two_salt.py. This flowsheet is meant to be an example of using the unit model diafiltration_two_salt.py. The unit model is tested already in test_diafiltration_two_salt.py. Should I write another (redundant) test file for the flowsheet example?

@bpaul4
Copy link
Contributor

bpaul4 commented Dec 17, 2025

@mollydougher yes I would suggest adding a test file to ensure that the flowsheet is covered and that it works as expected. Something simple, like smoke test the main method and check some notable results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority:Normal Normal Priority Issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants