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

Recommiting first API #2

Merged
merged 51 commits into from
Sep 12, 2024
Merged

Recommiting first API #2

merged 51 commits into from
Sep 12, 2024

Conversation

avdudchenko
Copy link
Contributor

This is recommit of the main API.

Please review as needed.

Copy link

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

Some initial comments on ReaktoroBlock. I will probably have more suggestions once I look into the sub-classes more.

self.build_rkt_solver(self.speciation_block, speciation_block=True)
self.build_gray_box(self.speciation_block)

self.build_rkt_state(

Choose a reason for hiding this comment

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

It looks like most of this is the same as what happens in the else branch (the default for speciation_block is False as far as I can tell).

Thus, I think you can make the if branch just for the speciation block, and then just run most of the else part for all cases. The only difference I see if whether speciation_block_built is True or not, which can be set in the if branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

speciation_block_built=False,
input_composition=None,
):
"""this will buld our rkt state specified block.

Choose a reason for hiding this comment

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

Typo: Capital to start doc string, "buld" -> "build".

Should "rkt" be expanded for later readers of the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


"""

""" defining which indexes shold be indexed

Choose a reason for hiding this comment

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

Typo: leading capital, indexes -> indices, shold -> should

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

if specific input is set to be not Indexed the index will be set to None"""

index = self.index()
composition_indexed = index

Choose a reason for hiding this comment

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

An inline comment as to why these are needed might be helpful - my initial reaction was that they were unnecessary until I read the next part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


convert_to_rkt_species = self.config.convert_to_rkt_species
pH = self.config.pH
if speciation_block == False:

Choose a reason for hiding this comment

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

Minor comment, but using and would make this only one line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed (legacy code...)

src/reaktoro_pse/reaktoro_block.py Outdated Show resolved Hide resolved
)
block.rkt_block_builder.build_reaktoro_block()

def display_jacobian_outputs(self):

Choose a reason for hiding this comment

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

Rather than a logger here, I would suggest allow the user to provide a stream object (generally a StringIO), and if not defaulting to stdout. This makes i ta bit easier to handle and test the output.

Also, looking at these I wonder if most of the code could be moved to the jacobian object and this method just be a wrapper around that (sort of like how it already calls rkt_jacobian.display_jacobian_output_types, but move all the code to there).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that would make sense. I will look into it.

else:
self.rkt_block_builder.set_user_jacobian_scaling(user_scaling_dict)

def initialize(self):

Choose a reason for hiding this comment

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

Is this equivalent to the existing process_block.initialize() method from IDAES?

If so, we should probably instead move to an Initializer object, as we plan to deprecate the model.initialize() API in the future. For backward compatibility, we can keep the initialize method, but have it just wrap the Initializer instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will put a todo for this.

@andrewlee94
Copy link

Also, a quick link to the previous PR where I made some additional comments before it was closed: #1

@avdudchenko avdudchenko changed the title Recomming first API Recommiting first API Aug 30, 2024
@avdudchenko
Copy link
Contributor Author

The last commit includes final updates to API that adds support to liquid phases, condensed phases and solid phases. This also updates some of the structure to improve the extensibility of the API and adds a tutorial for combustion calculations that shows how databases can be modified and used with the ReaktoroBlock directly. After this point only minor API and tests fixes will be implemented.

@avdudchenko avdudchenko merged commit 33b4cf1 into watertap-org:main Sep 12, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants