Giter Site home page Giter Site logo

psychrometrics / psychrolib Goto Github PK

View Code? Open in Web Editor NEW
212.0 212.0 59.0 3.48 MB

📚 Library of psychrometric functions to calculate 🌡️ thermodynamic properties of air for Python, C, C#, Fortran, R, JavaScript and VBA/Excel

License: MIT License

C 12.87% JavaScript 14.27% Fortran 12.26% TeX 0.44% Python 15.81% C# 16.69% Batchfile 0.01% VBA 11.24% R 16.43%
ashrae c csharp dew-point-temperature engineering excel fortran humidity hvac javascript meteorology moist-air net pressure psychrometrics python relative-humidity temperature thermodynamic-properties vba

psychrolib's People

Contributors

6nv avatar carbenium avatar didierthevenard avatar djgosnell avatar dmey avatar hongyuanjia avatar michaellass avatar semiamaurotic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

psychrolib's Issues

GetTDewPointFromTWetBulb error?

Describe the bug
I'm using the following in python
psy.SetUnitSystem(psy.IP)
psy.GetTDewPointFromTWetBulb(100, 40, 12.23) and the answer is -126.65009138804012

To Reproduce
Steps to reproduce the behavior:

  1. Open Python
  2. psy.SetUnitSystem(psy.IP)
  3. psy.GetTDewPointFromTWetBulb(100, 40, 12.23)
  4. -126.65009138804012

Expected behavior
The dew point at 100Fdb and 40Fwb at 12.23 psi barometric pressure would not give a negative dew point.

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser chrome
  • Version 91.0.4472.124 (Official Build) (64-bit)

Add functions to convert to dry bulb temperature or humidity ratio from enthalpy

EDIT: This issue is now for 2 functions given their similarity -- GetTDryBulbFromEnthalpyAndHumRatio and GetTDryBulbFromEnthalpyAndHumRatio

Working branch: GetTDryBulbFromMoistAirEnthalpy

Reference language implementation: Fortran


GetTDryBulbFromMoistAirEnthalpy

Completed implementations

Tick once implementation has been completed

  • Fortran
  • Python
  • C
  • JS
  • VBA/Excel

Completed tests

Tick one once tests has been written for the specific implementation

  • Fortran
  • Python
  • C
  • JS
  • VBA/Excel

Docs

  • Have the docs been updated?

GetTDryBulbFromEnthalpyAndHumRatio

Completed implementations

Tick once implementation has been completed

  • Fortran
  • Python
  • C
  • JS
  • VBA/Excel

Completed tests

Tick one once tests has been written for the specific implementation

  • Fortran
  • Python
  • C
  • JS
  • VBA/Excel

Docs

  • Have the docs been updated?

Example of js psychrometric chart

Is your feature request related to a problem? Please describe.
Demo of psychrolib.js to create a JS psychrometric chart based on altitude and values returned by psychrolib.js library.

Describe the solution you'd like
Made this gist as a demo of the JS implementation of your psychrolib. I've used chart.js as a charting library which is also MIT licensed.
Implement my code if you wish as a demo html file in your library for JS under MIT license.

Describe alternatives you've considered
One great solution is use also MIT licensed two.js to draw the graph instead of chart.js that I used, in order to display labels and limit the graph or display comfort zones which cannot be done in chart.js without plugins.

Additional context

CalcPsychometricsFromRelHum giving very wrong output

Describe the bug
psylib.CalcPsychometricsFromRelHum(12.7778, 0.50, 1021.141582)

returns the following:
(1.6217676478843839, 12.777467921950349, 2.624422024555517, 738.0866631026021, 4107439.3429013407, 289.9551674046484, 16217676.47884384)

For example: Enthalpy should be around 24000 J/kg (not 4107439), humidity ratio should be around 0.005 kgm/kga (not 1.62)

To Reproduce
Steps to reproduce the behavior:
Just run above line: psylib.CalcPsychometricsFromRelHum(12.7778, 0.50, 1021.141582)

Expected behavior
For example: Enthalpy should be around 24000 J/kg (not 4107439), humidity ratio should be around 0.005 kgm/kga (not 1.62)

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Ventura 13.3
  • Browser Safari
  • Version Python 3 in Jupyter

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

I want to calculate HumRatio from Enthalpy, Relative Humidity, and Pressure

I am working on research to make an automated fogging cooling system by sensing current humidity and set the target humidity.

I want to calculate Absolute Humidity from Enthalpy, Relative Humidity, and Pressure.

There is an exisiting function to find HumidityRatio in this library:
psychrolib.GetHumRatioFromRelHum(TDryBulb, RelHum, Pressure)

The problem is that function also needs TDryBulb. In my case, I don't have the TDryBulb, but I have the enthalpy, relative humidity and pressure. Conventionally I use the psychrometric chart to find the answer. But for this case, I need to use python to calculate this value.

Is there any existing function that can help me with this case? I still cannot find the roundabout. Maybe I have to find the TDryBulb first by using enthalpy and RelHum, then put the value to existing formula and get the HumRatio. But there is also not exist in this library.

I've found someone create a polynomial function to find enthalpy from TDryBulb and Relhum, but I cannot make it working otherwise to find the TDryBulb from enthalpy and Relhum. Here is the reference. https://www.mrexcel.com/board/threads/excel-formula-for-calculating-airs-enthalpy-from-dry-bulb-temperature-and-relative-humidity.871843/

I hope there will be new feature to include function:
GetHumRatioFromRelHumAndEnthalphy(Enthalphy, RelHum, Pressure)
or GetTdrybulbFromEnthalphy(Enthalphy, Relhum, Pressure)

Or is there anyone can help to drop the formula? I really appreciate that.

calc error with javascript

Download form github latest version

var psychrolibSI = require('../../utils/psychrolib.js')
psychrolibSI.SetUnitSystem(psychrolibSI.SI)
var result= psychrolibSI.CalcPsychrometricsFromTWetBulb(20, 15, 101325);
console.log(result)
0:1e-7
1: -87.10730529927714
2: Infinity
3: 0.016291630885105456
4: 20120.25382
5: 57.43149724107621
6: 1

anything wrong with my code?

GetTDryBulb

sometimes need

Get TDryBulb From WetBuld and RH,or WB and HumRatio,or RH and HumRatio

even MoistAirEnthalpy and HumRatio

Structure, docs and tests

I will be making structural changes and produce documentation for the Fortran (to start with) code. I will be doing this in branches but I wanted to ask you if you are happy for me to send you pull requests for every major change. I will also be adding some tests using the functions inside Energy Plus as a benchmark for your/our implementations so that they can be checked and evaluated against a well know implementation. Are you happy with this as well and will you be looking to merge all this? Thanks

GetTWetBulbFromHumRatio does not expected results

I am using the GetTWetBulbFromHumRatio but noticed that the results are not as expected. when compared against EnergyPlus (PsyTwbFnTdbWPb, see this) or https://www.weather.gov/epz/wxcalc_rh, the results from GetTWetBulbFromHumRatio suggest an issue with the pressure.

E.g.

Temperature = 10.0 deg C
Humidity ratio = 0.0001 kg/kg
Pressure = [80000, 140000] Pa
 Pressure:    80000.000000000000
 GetTWetBulbFromHumRatio:   -1.5518645498801780      PsyTwbFnTdbWPb:  -0.88337304600021549
 --------------------------------------------------------------------
 Pressure:    90000.000000000000
 GetTWetBulbFromHumRatio:  -0.85689781113800689      PsyTwbFnTdbWPb:  -0.20562830125160234
 --------------------------------------------------------------------
 Pressure:    100000.00000000000
 GetTWetBulbFromHumRatio:   0.43708771369073951      PsyTwbFnTdbWPb:   0.40338928189695028
 --------------------------------------------------------------------
 Pressure:    110000.00000000000
 GetTWetBulbFromHumRatio:   0.98029150820405553      PsyTwbFnTdbWPb:   0.94753667228016969
 --------------------------------------------------------------------
 Pressure:    120000.00000000000
 GetTWetBulbFromHumRatio:    1.4604243562908890      PsyTwbFnTdbWPb:    1.4288966335071569
 --------------------------------------------------------------------
 Pressure:    130000.00000000000
 GetTWetBulbFromHumRatio:    1.8890212226606971      PsyTwbFnTdbWPb:    1.8584618711636722
 --------------------------------------------------------------------
 Pressure:    140000.00000000000
 GetTWetBulbFromHumRatio:    2.2742148244443414      PsyTwbFnTdbWPb:    2.2446875369332200
 --------------------------------------------------------------------

I have not looked at this yet in detail as to the issue is with the implementation or with and issue/limitation in the ASHRAE formulae.

variables in js version

Mac Os: 10.15.6
Node: v14.11.0

I don't know if these are bugs but it is what I had to do to get this to work:

*Node had an issue with PSYCHROLIB_TOLERANCE not being declared.

*Also with HumRatio in: this.GetHumRatioFromTWetBulb = function
HumRatio = INVALID

*Didn't like log as a variable name in var log = Math.log; Changed vars to const and let throughout.

*ES Modules in Node >= 14 no longer have require by default. I am new at this but I used import instead of require.

After these changes it worked fine.

installing this package can't complete

hi is there anyone could help with?
if i run the following code:

from distutils.core import setup

setup(name='PsychroLib',
      version='2.5.0',
      maintainer = 'The PsychroLib Developers',
      description='Library of psychrometric functions to calculate thermodynamic properties of air',
      author='D. Thevenard and D. Meyer',
      author_email='[email protected]',
      url='https://github.com/psychrometrics/psychrolib',
      license='MIT',
      platforms = ['Windows', 'Linux', 'Solaris', 'Mac OS-X', 'Unix'],
      python_requires='>=3.6',
      py_modules=['psychrolib'],
     )

i got the following:

/anaconda3/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'python_requires'
  warnings.warn(msg)

An exception has occurred, use %tb to see the full traceback.

SystemExit: usage: ipykernel_launcher.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: ipykernel_launcher.py --help [cmd1 cmd2 ...]
   or: ipykernel_launcher.py --help-commands
   or: ipykernel_launcher.py cmd --help

error: option -f not recognized


/anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py:3304: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
  warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)

Add functions to convert between specific humidity and humidity ratio (aka mixing ratio)

Add functions to convert between specific humidity and humidity ratio (aka mixing ratio).
Proposed reference: ASHRAE Handbook - Fundamentals (2017) ch. 1 eqn 9b
Proposed name: GetHumRatioFromSpecificHum and GetSpecificHumFromHumRatio

Working branch: specific-hum

Reference language implementation: Fortran

Completed implementations

Tick once implementation has been completed

  • Python
  • C
  • Fortran
  • JS
  • VBA/Excel

Completed tests

Tick one once tests has been written for the specific implementation

  • Python
  • C
  • Fortran
  • JS
  • VBA/Excel

Docs

  • Have the docs been updated?

Documentation of magic numbers

I'm frustrated by the fact that constants are included in the calculations with no documentation of what they mean. For example

HumRatio = ((2501. - 2.326 * TWetBulb) * Wsstar - 1.006 * (TDryBulb - TWetBulb)) \
                    / (2501. + 1.86 * TDryBulb - 4.186 * TWetBulb)

This makes it harder to compare the methods used to other methods, or to describe in words the method that is being used; for example in the 'methods' section of an academic publication.
The cited sources for the equations in psychrolib are behind a paywall. My institution does not have access to the ASHRAE handbook, and the price of it is rather steep.
This definitely makes me less likely to use this package in my work.

Prepare for 2.1.1 release

  • Update header in src files to reflect version 2.1.1.
  • Release new version on PiPy.
  • Create release and document log.
  • Upload ready-made Excel spreadsheets.

Reduce CI runtime for R

At the moment most of the time spent in CI is due to R (building dependencies). @hongyuanjia do you know if we can use pre-compiled binaries? Or do you know of other ways to considerably reduce the build time for the R version?

Comfort zones implementation

Is your feature request related to a problem? Please describe.
Implement comfort zones based on Ashrae 55-2017 or EN 15251-2007

Describe the solution you'd like
Range of comfort zone between dry bulb temperature, relative humidity.

Describe alternatives you've considered
True or false statement that given array of [dryBulb, relHumidity] is inside comfort zone or not.

Additional context
Add any other context or screenshots about the feature request here.

Add support for handling vectorised operations in Python

At the moment we only support scalar inputs, I do not know if there is any demand to support vector operations in other languages but in Python, I think that this would be a good addition.

Having said that, for now, and as a workaround, one can use numpy.vectorize to allow for vectorised operations in PsychroLib as follows:

numpy.vectorize(psychrolib.function_name)

E.g.

import numpy as np
import psychrolib as psy
specific_humidity = [0.0001, 0.0002]
v_GetHumRatioFromSpecificHum = np.vectorize(psy.GetHumRatioFromSpecificHum)
humidity_ratio = v_GetHumRatioFromSpecificHum(specific_humidity)
print(humidity_ratio)
array([ 0.00010001,  0.00020004])

Prepare for 2.2.0 release

  • Update header in src files to reflect version 2.2.0.
  • Release new version on NuGet.
  • Release new version on PiPy.
  • Create release and document log.
  • Upload ready-made Excel spreadsheets.

`calcz` doesn't handle many numeric types due to overly-restrictive type-signature in `cardan`.

Example 1: bigfloats

spechum(MoistAir, big"300", WetBulb, 291.15, 101325.0)

gives

ERROR: MethodError: no method matching cardan(::Tuple{BigFloat, BigFloat, Float64, Float64})
Closest candidates are:
  cardan(::NTuple{4, T}) where T<:AbstractFloat at ~/external/Psychro.jl/src/utilities.jl:80

ForwardDiff also fails:

using ForwardDiff
spechum_t(t) = spechum(MoistAir, t, WetBulb, 291.0, 101325.0)
ForwardDiff.derivative(spechum_t, 293.0)

with

ERROR: MethodError: no method matching cardan(::Tuple{ForwardDiff.Dual{ForwardDiff.Tag{typeof(spechum_t), Float64}, Float64, 1}, ForwardDiff.Dual{ForwardDiff.Tag{typeof(spechum_t), Float64}, Float64, 1}, Float64, Float64})
Closest candidates are:
  cardan(::NTuple{4, T}) where T<:AbstractFloat at ~/external/Psychro.jl/src/utilities.jl:80

The obvious thing to do is just remove the constraint (and the uses of T() inside the function).
This works fine (including still working with Unitful quantities, as those are dealt with higher up in the call-stack).

However examining the function closer, cardan is passed information it cannot use, as the last element must always be 1.
In addition, as cardan is not exported, and only called calcz, the second-to-last element is always -1.0, but isn't reflected in cardan.

I would recommend:

  1. rename cardan to make clear it isn't the normal cardano algorithm and only handles cases with 1.0x^3 + ...,
  2. specialize it to 1.0 x^3 - 1.0 x^2 + ...,
  3. make it take two arguments, rather than a tuple, with each argument separately descending from Real.
  4. actually work out the consequences, though julia/llvm might be smart enough to just deal with it setting E1
  5. keep the constants as Float64 (as almost anything will be able to multiply by Float64s, though 1/3 as 0.33333... loses some precision with e.g. BigFloat. 1//3 might specialize well enough though?)

I'd be glad to submit a pull-request that does whatever subset of this you think is appropriate.

Get a runtime warning when using plot function

Hi, I tried this library with some examples in the notebook.

It shows this error when I use the plot function " RuntimeWarning: divide by zero encountered in GetRelHumFromTWetBulb
GetSatVapPres(db_t) * GetRelHumFromTWetBulb(db_t, wb_t, p_atm),"

Please advise the way to get rid of this error. Many thanks!

GetTDewPointFromHumRatio fails with NaN input

The GetTDewPoint methods (and, therefore, also any other methods that use dew points internally) have an iterative calculation inside them that fails to converge when called with NaN as input.

To Reproduce

psychrolib.GetTDewPointFromRelHum(25, np.nan)
psychrolib.GetTDewPointFromHumRatio(np.nan, 0.010, 101325)

Result:
ValueError: Convergence not reached in GetTDewPointFromVapPres. Stopping.

Expected behavior
Should return NaN, as happens with, e.g., psychrolib.GetHumRatioFromRelHum(25, np.nan, 101325). This also dovetails with supporting vectorised operations; it's helpful & efficient to be able to run the library methods on vectors that include missing data indicated with NaN.

Incorrect test in Psychrometic function: GetTDewPointFromVapPres().

The following range check at line 285 in the file 'psychrolib/src/js/psychrolib.js' appears to incorrectly use && rather than ||, or should be surrounded by a !().

EXISTING CODE:

  // Bounds outside which a solution cannot be found
  if (VapPres <= this.GetSatVapPres(_BOUNDS[0]) && VapPres >= this.GetSatVapPres(_BOUNDS[1]))
    throw new Error("Partial pressure of water vapor is outside range of validity of equations");

PROBABLE INTENDED CODE:

  // Bounds outside which a solution cannot be found
  if (!(VapPres <= this.GetSatVapPres(_BOUNDS[0]) && VapPres >= this.GetSatVapPres(_BOUNDS[1])))
    throw new Error("Partial pressure of water vapor is outside range of validity of equations");

As _BOUNDS[0] is always less than _BOUNDS[1], the existing check will not work.


Full path to the file being referenced in this bug report:
https://github.com/psychrometrics/psychrolib/blob/59d085b2df276578b4ead6b1fd5c8d6ce0e91520/src/js/psychrolib.js

Psychometric chart question

I'm a relatively new Python user, so I am a bit unfamiliar with the navigation and syntax. However, is there a way to input a minimum set of parameters which close the solution to the function and list out the remaining values at that point on the chart?

Prepare for 2.1 release

  • Update header in src files to reflect version 2.1.
  • Release new version on PiPy.
  • Create release and document log.
  • Upload ready-made Excel spreadsheets.

Prepare for 2.5.0 release

  • Update header in src files to reflect version 2.5.0.
  • Update manual tests for Excel
  • Create release and document log.
  • Release new version on PyPi.
  • Release new version on NuGet.
  • Release new version on CRAN.
  • Upload ready-made Excel spreadsheets.

@hongyuanjia @DJGosnell I have just released a new version due to some improvements to the Python version. When you have time, could you please release a new version on NuGET and CRAN?

How to calcuate psychrometric properties in Excel with PsychroLib

I am trying to use this in the excel sheet. I am unable to use your PsychroLib_2.2.2_SI macro-enabled excel worksheet as it is in a protected view. I downloaded it from releases.
https://github.com/psychrometrics/psychrolib/releases
I have tried to 'enable all macos', also tried to uncheck 'Enable protected view for files originating from the internet' But still, I can't see anything in the excel sheets.
Can you tell me how to open this?

Add Excel spreadsheets to releases

Specifically for VBA/Excel, I think it would be a good idea to add the ready-made spreadsheets (i.e. with PsychroLib already included) for the IP and SI version to the releases so that users who want to make use of PsychroLib in Excel can simply download the spreadsheet instead of having to download the repo and add the VBA script manually. @didierthevenard what do you think?

Calculations of wet bulb when dry bulb above 100 C converge to unreasonable value

The calculations of wet bulb when dry bulb when above 100 C are not handled properly.
The convergence tests implemented (test_GetTDewPointFromVapPres_convergence) converge to unreasonable values when hen above 100 C. For example GetTWetBulbFromRelHum(TDryBulb, RelHum, Pressure) with TDryBulb = 25, RelHum = 1 and Pressure = 101325. As expected the function returns 25 (when the air is saturated, wet bulb = dew point = dry bulb). With TDryBulb = 99 it returns 99.. When called with TDryBulb = 101 it returns 43.

Format of DOIs and URLs in the R package

This is a follow-up of #72. CRAN still found 2 issues for the current submissions:

  1. The current format still did not comply with CRAN requirements.
  2. There should not be any URLs that need redirection. See CRAN URL-Checks

Please see the email from CRAN:

   Found the following (possibly) invalid URLs:
     URL: https://pypi.org/project/PsychroLib (moved to
https://pypi.org/project/PsychroLib/)
       From: README.md
       Status: 200
       Message: OK

Please add the trailing slash.


   The Description field contains
     D. and Thevenard, D (2019) <doi.org:10.21105/joss.01137>.
   Please write DOIs as <doi:10.prefix/suffix>.

Please fix and resubmit.

Prepare for 2.4.0 release

  • Update header in src files to reflect version 2.4.0.
  • Release new version on NuGet.
  • Release new version on PyPi.
  • Release new version on CRAN.
  • Create release and document log.
  • Upload ready-made Excel spreadsheets.

@hongyuanjia @DJGosnell I will let you know once the headers have been updated and all is in order for release on NuGET and CRAN.

Fix the DOI links in the DESCRIPTION file of the R package

I got an email from CRAN maintainers saying that all DOIs should migrate to the new style: <doi:10.prefix/suffix>.

Currently, we use <doi.org/10.21105/joss.01137>. Should resubmit before Feb 03. This issue should be fixed together with #64

Email from CRAN maintainers

These give DOIs in the DESCRIPTION Description field differently from
the preferred

  <doi:10.prefix/suffix>

way (and often in a way preventing hyperlinking in the package web
pages), see below.

Can you please fix as necessary, and submit new versions of your
packages before 2021-02-03?

Note that this will be the *final* reminder.

Best
-k

Requesting Additional info

By giving fresh air and return air temperature and humidity, we can get mixed air temperature point details. Can you develop code for this point also. it will very helpful. thank you very much

GetDryBulbFromWetBulb(WetBulb, HumRatio)

Is your feature request related to a problem? Please describe.
I cant calculate dry bulb temperature from wetbulb temperature and absolute HumRatio.

Describe the solution you'd like
Create function that calculates dry bulb temperature from wetbulb temperature and absolute HumRatio.

Describe alternatives you've considered
I tried calculating it with existing functions. But it needs enthalpy which needs drybulb...

Inconsistent labeling of Humidity Ratio in documentation

Describe the bug
The definition of Humidity Ratio is inconsistent between different function argument descriptions.

E.g. for GetTDryBulbFromEnthalpyAndHumRatio it is defined as

HumRatio : Humidity ratio in lb_H₂O lb_Air⁻¹ [IP] or kg_H₂O kg_Air⁻¹ [SI]

but for GetSpecificHumFromHumRatio it is defined as

HumRatio : Humidity ratio in lb_H₂O lb_Dry_Air⁻¹ [IP] or kg_H₂O kg_Dry_Air⁻¹ [SI]

where the latter is accurate and more descriptive but the former is more extensively used in the psychrolib function argument documentation. Given that humidity ratio vs specific humidity tends to be a source of confusion, I suggest the definition of HumRatio in the documentation should be consistently specified to the second one above.

Test files do not run in Python

Describe the bug
When attempting to use PyTest to run the test files, each file independently reports:
ModuleNotFoundError: No module named 'psychrolib_fortran'

To Reproduce
Steps to reproduce the behavior:

  1. Clone repo
  2. Navigate to repo location in terminal
  3. Enter: pytest test_psychrolib_si.py

Expected behavior
I expected a small report to be generated declaring how many tests had passed and failed.

Desktop (please complete the following information):

  • OS: Ubuntu 18.04.01 LTS
  • Browser: Chrome
  • Version: 2.0.0

Additional context
I could be approaching the test files incorrectly. My experience is limited with PyTest.

Prepare for 2.3.0 release

  • Update header in src files to reflect version 2.3.0.
  • Release new version on NuGet.
  • Release new version on PyPi.
  • Create release and document log.
  • Upload ready-made Excel spreadsheets.

Test Building of C# failing

Since commit 99bf247, the test suite for C# is failing. Currently researching why the c_sharp test is failing. I'll hopefully have some reason/solution by tomorrow.

May be related to #76

Implement psychrolib in R

It may be useful to add an implementation of psychrolib in the R language.

I am creating an R package for this purpose (all functions and tests are ported). Would you be interested in taking a merge request and maintaining the package in this repository, with the goal of ultimately submitting to CRAN?

Define and use thermodynamic constants

This is something to keep in mind for future releases -- I think it would make sense to use proper names for thermodynamic constants which are currently used and reported in PsychroLib as numbers. For example, in some functions, we use the number 2501.0 instead of using a global thermodynamic constant named latent heat of vaporisation of water or similar. There are not many we use so this would not be a lot of work.

Find the intersection of relative humidity and enthalpy lines

I am enjoying this library. Thank you for making it available.

I had to find the intersection point between RH lines and moist air enthalpy lines. I was using the js version and ended up writing this outside the library, following the bisection search code found in GetTWetBulbFromHumRatio.

You may consider adding this (and another one like it - to find the intersection of TWetBulb with RH) to the library itself if you wish.

function GetTDryBulbFromEnthalpyRelHum(MoistAirEnthalpy, RelHum, Pressure) {
  /*
  We want to determine the psychrometric properties from the moist air enthalpy 
  and relative humidity. These two lines (RH(T), h(T)) cross at one point. We find TDryBulb of this point.
  */
  var T_TOLERANCE = 1E-10;     

  var TDryBulbInf, TDryBulbSup, TDryBulb;
  var HumRatio, currRelHum;
  var index = 1;
  
  //initial guesses
  TDryBulbInf = psychrolib.GetTDryBulbFromEnthalpyAndHumRatio(MoistAirEnthalpy, 0);
  TDryBulbSup = psychrolib.GetTWetBulbFromRelHum(TDryBulbInf, 0, Pressure) - 2; //wet bulb T is above the enthalpy line, not good enough for high target RH. -2deg is enough to cover it
  TDryBulb = (TDryBulbSup + TDryBulbInf) / 2.;

  //bisection loop
  while ((TDryBulbInf - TDryBulbSup) > T_TOLERANCE) {
    //compute the relative humidity for the current guess of TDryBulb (first get Humidity Ratio)
    HumRatio = psychrolib.GetHumRatioFromEnthalpyAndTDryBulb(MoistAirEnthalpy, TDryBulb);
    currRelHum = psychrolib.GetRelHumFromHumRatio(TDryBulb,HumRatio, Pressure);

    //get new bounds
    if (currRelHum < RelHum)
      TDryBulbInf = TDryBulb;
    else
      TDryBulbSup = TDryBulb;

    //new guess for TDryBulb
    TDryBulb = (TDryBulbSup + TDryBulbInf) / 2.;

    if (index > MAX_ITER_COUNT)
      throw new Error("Convergence not reached. Stopping.");

    index++;
  }
  return TDryBulb;
}

Initial guess of bisection loop of GetTWetBulbFromHumRatio leading to an error for high dry bulb temperatures and high humidity ratios

Describe the bug
Dry bulb temperature returned by GetTWetBulbFromHumRatio for high dry bulb temperatures and high humidity ratios.

To Reproduce
Steps to reproduce the behavior:
psychrolib.GetTWetBulbFromHumRatio(150, 1,101325)
returns 149.9995190883829

Expected behavior
The wet bulb temperature should not exceed 100°C at standard sea level pressure.

Additional context
The issue is created by the lines and following code. The bisection loop starts with the maximum theoretical wet bulb temperature (WBT) and minimum theoretical WBT as initial bounds.
Min WBT --> dew point
Max WBT --> dry bulb temperature
The latter is not correct (for dry bulb temperatures >100°C at this pressure), as at standard sea level pressure, the WBT cannot exceed ~100°C. The code then takes the average of the min and max WBT and starts the iteration. If the average of dew point and dry bulb temperature is higher than the maximum possible WBT at this pressure, this line returns 0 and therefore the error occurs:
error

A solution would be to set initially the max WBT to the minimum of the dry bulb temperature and the boiling temperature of water at the given pressure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.