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

Code from Live-Page of PYroMat #85

Open
jettrich opened this issue Jan 8, 2024 · 2 comments
Open

Code from Live-Page of PYroMat #85

jettrich opened this issue Jan 8, 2024 · 2 comments

Comments

@jettrich
Copy link

jettrich commented Jan 8, 2024

Dear chmarti1,

I'm highly interested in using PYroMat for creating state diagrams and illustrating thermodynamic processes and cycles for my students, and I'd love to see the source code used to draw the T,s-diagram on the live site of the PYroMat website. Please, could you provide me with the code, in order to ease my point of entry in using PYroMat?

Kind Regards
Jörg

@chmarti1
Copy link
Owner

chmarti1 commented Jan 8, 2024

I'll refer you to (and tremendous credit is due to) my colleague, Joe Ranalli (@jranalli), who currently maintains all of the live code. In the meantime, there are various versions of development of the website that have historically been housed here.

@jranalli
Copy link
Collaborator

jranalli commented Jan 8, 2024

@jettrich thanks for your interest! It turns out that the code that draws that graph is pretty extensive, because there's a lot of fiddling that goes into figuring out exactly which lines will have decent spacing. It also depends a bit on how perfect you'd like it to look. For example, some of the phase transitions on enthalpy isolines in my plot do not show the exact intersection with the steam dome.

So that said, I put together a demo file that will plot a similar diagram to the live page. You can see it here. There are several helper functions that only exist to quickly gather data for the steam dome and isolines, while the real plotting happens in this section.

if __name__ == "__main__":
    water = pm.get("mp.H2O")
    sd_data = compute_steam_dome(water)

    plt.figure()
    plt.xlabel('s (kJ/kg-K)')
    plt.ylabel('T (K)')

    # Steam Dome
    for line in ['liquid', 'vapor']:
        plt.plot(sd_data[line]['s'], sd_data[line]['T'], 'k-')

    # P isolines
    for line in compute_iso_line(water, p=0, n=25, default=True):
        plt.plot(line['s'], line['T'], 'r-')

    # v isolines
    for line in compute_iso_line(water, v=0, n=25, default=True):
        plt.plot(line['s'], line['T'], 'b-')

    # h isolines
    for line in compute_iso_line(water, h=0, n=25, default=True):
        plt.plot(line['s'], line['T'], 'g-')

    plt.show()

I'm not sure what your starting point is as far as python knowledge goes, but if this is too much of a mess to jump right into, please say so and I can try to make a simpler introduction.

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

No branches or pull requests

3 participants