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

The necessary temperature unit is Kelvin. #12

Closed
NK-Aero opened this issue Apr 14, 2023 · 1 comment
Closed

The necessary temperature unit is Kelvin. #12

NK-Aero opened this issue Apr 14, 2023 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@NK-Aero
Copy link

NK-Aero commented Apr 14, 2023

Could you offer the option of using Kelvin as the temperature unit for both the input and all output properties?

I have added a sample code.

from pyfluids import Fluid, FluidsList, Input

def celsius_to_kelvin(temp_c):
return temp_c + 273.15

def kelvin_to_celsius(temp_k):
return temp_k - 273.15

def fluid_properties(fluid, pressure, temperature_k):
temperature_c = kelvin_to_celsius(temperature_k)
fluid_instance = Fluid(fluid).with_state(Input.pressure(pressure), Input.temperature(temperature_c))

properties = {
    "compressibility": fluid_instance.compressibility,
    "conductivity": fluid_instance.conductivity,
    "critical_pressure": fluid_instance.critical_pressure,
    "critical_temperature": celsius_to_kelvin(fluid_instance.critical_temperature),
    "density": fluid_instance.density,
    "dynamic_viscosity": fluid_instance.dynamic_viscosity,
    "enthalpy": fluid_instance.enthalpy,
    "entropy": fluid_instance.entropy,
    "internal_energy": fluid_instance.internal_energy,
    "kinematic_viscosity": fluid_instance.kinematic_viscosity,
    "max_pressure": fluid_instance.max_pressure,
    "max_temperature": celsius_to_kelvin(fluid_instance.max_temperature),
    "min_pressure": fluid_instance.min_pressure,
    "min_temperature": celsius_to_kelvin(fluid_instance.min_temperature),
    "molar_mass": fluid_instance.molar_mass,
    "phase": fluid_instance.phase,
    "prandtl": fluid_instance.prandtl,
    "pressure": fluid_instance.pressure,
    "quality": fluid_instance.quality,
    "sound_speed": fluid_instance.sound_speed,
    "specific_heat": fluid_instance.specific_heat,
    "surface_tension": fluid_instance.surface_tension,
    "temperature": celsius_to_kelvin(fluid_instance.temperature),
    "triple_pressure": fluid_instance.triple_pressure,
    "triple_temperature": celsius_to_kelvin(fluid_instance.triple_temperature),
}

return properties

selected_fluid = FluidsList.Nitrogen
pressure = 100e3
temperature_k = -20 + 273.15 # Convert -20°C to Kelvin

properties = fluid_properties(selected_fluid, pressure, temperature_k)
print(properties)

@NK-Aero NK-Aero changed the title All Temperature units should in Kelvin. The necessary temperature unit is Kelvin. Apr 14, 2023
@portyanikhin
Copy link
Owner

portyanikhin commented Apr 20, 2023

Hello, @NK-Aero!

This issue duplicates #8 (you can read the discussion). So I'll close it.

In a future version of PyFluids, the ability to select a units system using a configuration file will be implemented. Due to the large load in the very near future, I will not have time to implement it. I think I'll find the time next month.

If you want to speed up the process, you can make a pull request.

Thanks!

@portyanikhin portyanikhin added the duplicate This issue or pull request already exists label Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants