Files
CoolProp/Web/scripts/__init__.py
Ian Bell 267d64533a Superancillaries for pure fluids (#2511)
* Expansions are fully wrapped, looking good. Next step is the set of expansions that is the 1D approximation

* Get 1D approx working via cython

* Count solutions

* SuperAncillary class is working

>1000x speedup for water
Time for C++!

* Superancillaries are working!

In C++, speedup is more than 2000x. In Python, more like 150x because of Python <-> C++ overhead

* Add pmax check for PQ superancillary calls

* Update tests

* Allow T limits to be obtained

* Implement get_fluid_parameter_double for getting superanc value

* Add tests for getting parameters from superanc

* Script for testing superancillaries for sphinx

* Microoptimizations; don't help speed

The limiting factor remains the clear function, which takes about 30 ns

* Add R125 superancillary

* Use the release from fastchebpure for the files

* Drop a .gitignore in the unzipped folder

* Update superancillary injection script

* Turn on superancillaries by default

* Missing header

* Many int conversions in superancillary

* Another int cast

* More annoying solution for boost iter max

* Fix warnings

* One more warning

* Clear up the calculation of rho

* Update docs_docker-build.yml

Use arm64 since the containers were built on mac

* Superfluous ;

* Update backend.py

* Get the critical points working for superancillaries

* Fix wrapping changes of xmin&xmax methods

* squelch warnings

* Version 0 of jupyter notebook for docs

* Try to add the notebook to the docs

* Add jupyter notebook for superancillary

* Lots of updates to superancillary notebook

* More updates to docs

* Skip pseudo-pure for superancillary docs

* Fix output of superancillary figures

* Add superancillary plots to docs for the page for each fluid

* Make a placeholder figure for fluids without superancillary

* Add superancillary plots to task list

* Bump to release fixing m-xylene

* Relax the location of the REFPROP stuff

* Change default name for R-1336mzz(E)

* No need for figures to be so large

* Don't need REFPROP setting

* Bump to fastchebpure release with methanol

* Benchmark caching options

* Benchmark more granularly

* Add the fast methods to public API for HEOS class

* Back to memset - can memset with 0 but no other value

* Fix how caching is managed in Helmholtz class

* Close to final implementation

Perhaps a tiny bit more optimization possible?

* Update function name

* Make message more accurate

* Fix init order

* Expose update_QT_pure_superanc to Python

* Fix when _reducing is set for pures

* Fix the post_update

* Indent

* Notebook

* Notebook

* Make ln(p) construction lazy

Only really matters for debug builds

* Also make reference non-const

* Inject superancillary for methanol

* Make the superancillary loading entirely lazy in debug

* Fix PH bug for Nitrogen

 Closes #2470

* Force the clear to be called on SatL and SatV

To invalidate them at start

* Default is non-lazy superancillary loading

* Add CMake option to have lazy-loading superancillaries [skip ci]

Not a good idea unless doing very narrow testing
2025-05-17 20:27:19 -04:00

104 lines
3.8 KiB
Python

#!/usr/bin/env python
# -*- coding: utf8 -*-
import os.path, glob, subprocess, sys, time, datetime, pytz
# Start with detecting the full build
def detect_full_rebuild():
if len(sys.argv) >= 2:
arg = str(sys.argv[1]).lower()
if arg == "true": return True
if arg == "1": return True
return False
full_rebuild = detect_full_rebuild()
print("Detected rebuild argument: full_rebuild = {}".format(full_rebuild))
# File system functions
def touch(fname):
if os.path.exists(fname): os.utime(fname, None)
else: open(fname, 'a').close()
#
def get_ftime(fname):
if os.path.isfile(fname): return os.path.getctime(fname)
else: return 0
#
# Directory settings
script_root_dir = os.path.abspath(os.path.dirname(__file__))
repo_root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
task_list = []
def add_if_exists(fname):
if os.path.isfile(fname):
task_list.append(fname)
print("Added '{}' to the task list.".format(fname))
return True
return False
def add_to_task_list(fname_in):
fname = fname_in
if add_if_exists(os.path.abspath(fname)):
return True
fname = os.path.join(script_root_dir, fname_in)
if add_if_exists(os.path.abspath(fname)):
return True
fname = os.path.join(repo_root_dir, fname_in)
if add_if_exists(os.path.abspath(fname)):
return True
print("Error: Could not find '{}'.".format(fname_in))
return False
def run_script(path):
if os.path.exists(path):
file_path = os.path.dirname(path)
file_name = os.path.basename(path)
file_extension = path.split(".")[-1]
#file_name, file_extension = os.path.splitext(path)
if file_extension.lower() == "py":
subprocess.check_call('python -u {0}'.format(file_name), cwd=file_path, shell=True)
elif file_extension.lower() == "sh" or file_extension.lower() == "bsh":
subprocess.check_call('chmod +x {0}'.format(file_name), cwd=file_path, shell=True)
subprocess.check_call('sed -i "s/\r//g" {0}'.format(file_name), cwd=file_path, shell=True)
subprocess.check_call('./{0}'.format(file_name), cwd=file_path, shell=True)
else:
print("Unknown file extension in {0}".format(path))
else:
print("Could not find the file {0}".format(path))
# Inject the version of CoolProp into the doxygen configuration files
# Put it at the end, overwrites prior value
import CoolProp
with open(os.path.join(repo_root_dir, 'Doxyfile'), 'a+') as fp:
fp.write('\n\n PROJECT_NUMBER = {}\n'.format(CoolProp.__version__))
# The normal tasks that are carried out each time the script runs
print("Adding the normal scripts to the task list.")
if sys.platform == "linux":
add_to_task_list("dev/scripts/examples/LinuxRun.py")
elif sys.platform == "darwin":
add_to_task_list("dev/scripts/examples/OSXRun.py")
add_to_task_list("coolprop.tabular.speed.py")
add_to_task_list("fluid_properties.phase_envelope.py")
add_to_task_list("fluid_properties.PurePseudoPure.py")
add_to_task_list("fluid_properties.Mixtures.py")
add_to_task_list("fluid_properties.Superancillary.py")
add_to_task_list("coolprop.parametric_table.py")
add_to_task_list("coolprop.configuration.py")
add_to_task_list("logo_2014.py")
add_to_task_list("fluid_properties.REFPROPcomparison.py")
# The expensive tasks that are fired when full_rebuild is True
if full_rebuild:
print("Adding the computationally expensive scripts to the task list.")
add_to_task_list("fluid_properties.Consistency.py")
add_to_task_list("fluid_properties.Incompressibles.sh")
# Run all the files in the task list
print("Processing the selected tasks to generate the static files.")
for fname in task_list:
print("Executing {0}".format(fname))
run_script(os.path.normpath(fname))