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

1D Membrane Model for CO2 Capture and Utilization #1378

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

Morgan88888888
Copy link
Member

Summary/Motivation:

There is a new project ongoing to support NETL's reactive capture technology. The goal of this work is to integrate CO2-selective polymer membranes with electrochemical conversion to efficiently transform captured CO2 into formic acid. The unit and flowsheet models developed in the field of capturing and utilizing CO2 during this project will be maintained in this repository. These models will benefit other ongoing work, such as membrane design and process configuration optimization.

Changes proposed in this PR:

  • Created the workspace for ongoing CO2 Capture and Utilization modeling efforts to support NETL's reactive capture technology.
  • Developed a one-dimensional membrane model for CO2 capture.
  • Developed the model testing for 1D membrane model

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.txt 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.

@Morgan88888888 Morgan88888888 added models_extra Issues related to models in models_extra folder. CCU ongoing CO2 capture and utilization project labels Mar 19, 2024
@Morgan88888888 Morgan88888888 self-assigned this Mar 19, 2024
Copy link
Member

@andrewlee94 andrewlee94 left a comment

Choose a reason for hiding this comment

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

Here is a first batch of comments. Most are minor things and ways to do things better, and otherwise what I have seen so far looks good.

Some general comments are:

  1. Fix all the pylint issues (either by running pylint yourself or looking throguh the notifications here on GitHub).
  2. Fix the tests so that they run.
  3. We will also need some basic documentation to merge this PR.

@ksbeattie ksbeattie added the Priority:Normal Normal Priority Issue or PR label Mar 21, 2024
Copy link

codecov bot commented Mar 29, 2024

Codecov Report

Attention: Patch coverage is 82.75862% with 15 lines in your changes are missing coverage. Please review.

Project coverage is 77.63%. Comparing base (c09433b) to head (f6dc03b).
Report is 2 commits behind head on main.

Files Patch % Lines
...capture_and_utilization/unit_models/membrane_1d.py 82.55% 7 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1378      +/-   ##
==========================================
+ Coverage   77.60%   77.63%   +0.02%     
==========================================
  Files         391      393       +2     
  Lines       64333    64462     +129     
  Branches    14245    14272      +27     
==========================================
+ Hits        49926    50042     +116     
- Misses      11831    11841      +10     
- Partials     2576     2579       +3     

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

Copy link
Member

@andrewlee94 andrewlee94 left a comment

Choose a reason for hiding this comment

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

A number of comments. A few other things:

  1. There are a lot of lines of code that are not covered by tests (mostly things like different combinations of configurations). Whilst not required for models_extra, I would strongly encourage you to do at least minimal testing of the different configurations to ensure they at least build successfully.
  2. You do not have the methods required to support the report and stream table functionality (and thus the visualizer). Whilst again not critical, they would be a good thing to include for usability.
  3. You need to include some basic documentation. At a minimum of explaining what these models are for, the key equations and what degrees of freedom the user should set (this is especially important given my comment about selectivity).

One-dimensional membrane class for CO2 gas separation
"""

# pylint: disable=unused-import
Copy link
Member

Choose a reason for hiding this comment

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

Why is this being disabled? Enum is being used, so there should not be a warning issued by this.

self.cell_length = Expression(expr=self.length / self.config.finite_elements)

self.cell_area = Var(
initialize=100, units=units.cm**2, doc="The membrane area"
Copy link
Member

Choose a reason for hiding this comment

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

This needs a better doc string, as at the moment it is the same as self.area. I think this should be area per cell (or finite element to be more accurate).

self.selectivity = Var(
self.flowsheet().time,
self.mscontactor.elements,
self.mscontactor.feed_side.component_list,
Copy link
Member

Choose a reason for hiding this comment

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

Do you need the full factorial combination of these? I suspect you do not need the combination where both components are the same, and that S[i, j] == 1/S[j, i]. Looking below, I think this is confirmed by the following constraint.

Thus, my question becomes how do you intend for a user to use these? If a user were to naively fix all the selectivity, then the problem would be over-specified.

mb_units = feed_side_units.FLOW_MASS
rho = self.mscontactor.feed_side[t, s].dens_mass
else:
raise TypeError("Undefined flow basis, please define the flow basis")
Copy link
Member

Choose a reason for hiding this comment

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

Minor comment, but the flow basis is always defined, but we allow for it to be "other" (e.g. volume). A more correct error message would be "This model only supports MaterialFlowBasis equal to molar or mass".

assert m.fs.unit.config.property_package is m.fs.properties


class TestMembrane(object):
Copy link
Member

Choose a reason for hiding this comment

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

You do not need the (object) when declaring a class in Python 3.

initializer.initialize(membrane.fs.unit)
results = solver.solve(membrane)
# Check for optimal solution
assert check_optimal_termination(results)
Copy link
Member

Choose a reason for hiding this comment

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

This should be assert_optimal_termination (it combines the assert with check_optimal_termination for you).

@pytest.mark.solver
@pytest.mark.skipif(solver is None, reason="Solver not available")
@pytest.mark.component
def test_enthalpy_balance(self, membrane):
Copy link
Member

Choose a reason for hiding this comment

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

You should also check for material conservation here.

@andrewlee94
Copy link
Member

Also, Sphinx is complaining about a doc string in you model. I think you need to add a line break at the end of line 57 in you model.

@ksbeattie
Copy link
Member

@Morgan88888888 any update on this?

@Morgan88888888
Copy link
Member Author

@Morgan88888888 any update on this?

I am working on it and should be ready this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CCU ongoing CO2 capture and utilization project models_extra Issues related to models in models_extra folder. Priority:Normal Normal Priority Issue or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants