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

Create a state class #81

Open
chmarti1 opened this issue Jan 20, 2023 · 2 comments
Open

Create a state class #81

chmarti1 opened this issue Jan 20, 2023 · 2 comments

Comments

@chmarti1
Copy link
Owner

chmarti1 commented Jan 20, 2023

This was originally posted by @DanielSarmiento04 as a comment in #77. I've re-posted it here because it's an interesting idea.

         I have been using the library for the past few months in parallel to a thermodynamics course

I like the piromat ecosystem

I made this repository when I used for solve Brayton, Rankine and >combine Cicle, these example you can use for tutorials.

Another suggestion that I found is the next

  • Simply code
    Normally, for optimize time processed and debugger I use
    state_x = 'fluid'.state('propierties')

this return a dictionary and for mapping the information we have to use .get dictionary method
h_x = state_x.get('h')
something to improve is use the status type objects

  • Example
class State(object):
  h
  s
  T
  v
 # Some propierties

and then use h_x = state_x.h

Originally posted by @DanielSarmiento04 in #77 (comment)

@chmarti1
Copy link
Owner Author

I thought about doing this when I wrote the state methods. There are a couple of reasons I decided not to do it yet, but that doesn't mean it will never happen

  1. It is awkward to write a single state class that can represent data from all substances. For example, quality and saturation properties are meaningless for an ideal gas. These are issues that can be dealt with, but they can also be dealt with by a dictionary.
  2. In my opinion, promoting a dictionary to a class is best done only when implementing class methods is important. The state class would merely be a container for the property values.
  3. There are plans to add additional properties soon, which would make this an awkward time to design a class that could represent all properties.

Still, I think this is still a good idea, so it's worth opening it for discussion.

@jranalli
Copy link
Collaborator

2. In my opinion, promoting a dictionary to a class is best done only when implementing class methods is important.  The state class would merely be a container for the property values.

Thinking out loud here, so please excuse. One method that would maybe be of value is wrappers for quickly converting the units for all properties an already computed state. But that doesn't necessarily have to be a class function as opposed to a function that can operate on the dict. The one advantage I could see for a class approach would be to carry the units along with the values as an extra field. In principle that could happen with the dict but might be messier?

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

No branches or pull requests

2 participants