def test(): for c in sys.components: for p in [e for e in Properties]: fdesc = c.functions[p] T = Variable("T", 273.15, SI.K) T.displayUnit = METRIC.C TC = c.constants[PhysicalConstants.CriticalTemperature] PC = c.constants[PhysicalConstants.CriticalPressure] f = sys.correlationFactory.createFunction(fdesc, T, TC, PC) for i in range(2000): T.value = random.uniform(100.0, 550.0) f.reset() y = f.eval()
from pypedream.thermodynamics import PureComponentFunctionFactory, Substance, ThermodynamicSystem, Properties, PhysicalConstants from pypedream.database import purecomponents as pcdb import math import numpy as np import streamlit as st import pandas as pd import plotly.express as px sys = ThermodynamicSystem("Test") sys.addComponent(pcdb.Water()) sys.addComponent(pcdb.Isopropanol()) sys.addComponent(pcdb.Methanol()) T = Variable("T", 273.15, SI.K) T.displayUnit = METRIC.C c = st.sidebar.selectbox('Substance', sys.components, format_func=str) p = st.sidebar.selectbox('Property', [e for e in Properties]) fdesc = c.functions[p] tmin = st.sidebar.slider('Minimum Temperature', -100, 500, 25) tmax = st.sidebar.slider('Maximum Temperature', -100, 500, 200) samples = st.sidebar.number_input('samples', 10, 150) TC = c.constants[PhysicalConstants.CriticalTemperature] PC = c.constants[PhysicalConstants.CriticalPressure] f = sys.correlationFactory.createFunction(fdesc, T, TC, PC) def calculate(): x = []
import numpy as np import streamlit as st import pandas as pd import plotly.express as px import plotly.graph_objects as go sys = ThermodynamicSystem("Test", "NRTL") sys.addComponent(pcdb.Water()) sys.addComponent(pcdb.Ethanol()) sys.addComponent(pcdb.Methanol()) sys.addComponent(pcdb.Acetone()) sys.addComponent(pcdb.Isopropanol()) sys.fill() T = Variable("T", 273.15, SI.K) T.displayUnit = METRIC.C P = Variable("P", 1e5, SI.Pa) P.displayUnit = METRIC.mbar c1 = st.sidebar.selectbox('Substance 1', sys.components, format_func=str, index=0) c2 = st.sidebar.selectbox('Substance 2', sys.components, format_func=str, index=1) tiso = st.sidebar.slider('Isothermal Temperature [°C]', -100, 300, 25) piso = st.sidebar.slider('Isobaric Pressure [mbar]', 100, 5000, 1013)