Commit Graph

40 Commits

Author SHA1 Message Date
Ian Bell
6f8b4c95e2 Use requests with retry adapter for PubChem SDF downloads (#2730)
Replaces urllib with requests + HTTPAdapter/Retry to get automatic
retries (up to 3) with exponential backoff on 429/5xx and network
errors; 404 is treated as a definitive miss and skips to 2D without
retrying.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 20:08:58 -04:00
Ian Bell
c649586e8c feat(docs): add interactive 3D molecule viewers to fluid pages (#2707)
* feat(docs): add interactive 3D molecule viewers to fluid pages

Use py3Dmol + PubChem SDF data to embed a rotate-and-drag 3D (or 2D
fallback) molecule viewer on each pure fluid documentation page.

- fetch_pubchem_sdf(): downloads 3D conformer SDF from PubChem REST API
  (falls back to 2D), caching results in molecule_sdf/ to avoid repeated
  network calls on doc rebuilds
- generate_3dmol_rst(): inlines the SDF as a JS template literal inside a
  .. raw:: html block — no extra static files needed at Sphinx build time
- FluidGenerator.write(): validates InChIKey with regex before fetching;
  pseudo-pure fluids (Air, R404A, etc.) without InChIKeys are silently skipped
- conf.py: loads 3Dmol.js from CDN via html_js_files
- .gitignore: excludes the generated molecule_sdf/ cache directory

Restores molecule visualisation that was removed in April 2025 (the old
approach tried to embed an image directive inside a CSV table, which is
invalid RST; this implementation places the viewer in the RST template).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(docs): serve 3Dmol.js locally to eliminate CORS errors

Download 3Dmol-min.js to _static/ at Sphinx build time (same pattern
as MathJax) instead of loading it from the CDN via html_js_files.
Serving the script same-origin removes the cross-origin restriction
that caused CORS errors when docs were opened from file:// or a local
dev server.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(docs): correct 3Dmol viewer positioning and initialization timing

3Dmol.js sets its canvas to position:absolute;top:0;left:0 and only
auto-sets the container to position:relative when the container's
inline style.position === "static". An unstyled div has style.position
=== "" so the check fails, and the canvas escapes the container and
anchors to the nearest positioned ancestor in the Sphinx page layout.

Fix: add position:relative explicitly to the viewer container div.

Also defer viewer init via DOMContentLoaded so layout is finalized
before createViewer reads the container dimensions, and call v.resize()
before v.render() to sync the WebGL canvas to the container size.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(docs): disable MathJax SRE to prevent CORS errors on file:// URLs

MathJax 4.0's Speech Rule Engine fetches sre/mathmaps/base.json at
runtime via fetch(). Chrome blocks this when docs are opened from a
local file:// URL (null origin). Disabling enableExplorer and
enableAssistiveMml prevents SRE from initialising entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(docs): load 3Dmol before require.js to fix AMD conflict

sphinx.ext.mathjax injects require.js at priority 500. When 3Dmol
loads after it, AMD detection fires and calls define([], factory)
instead of setting window.$3Dmol directly. Since nothing ever calls
require(['3Dmol-min']), the factory never runs and the viewer silently
fails (infinite setTimeout retry, no console errors).

Setting priority 450 ensures 3Dmol loads before require.js.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(docs): add retry logic to downloads in conf.py using requests

Replace urllib.request.urlretrieve with a requests-based _download()
helper that retries up to 5 times (exponential backoff, factor=2) on
transient HTTP errors and timeouts. Fixes CI build failures when
the MathJax or 3Dmol.js downloads time out.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 10:41:10 -04:00
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
Ian Bell
b19c29128d Render the formulae with roman characters [skip ci] 2025-04-21 11:01:27 -04:00
Ian Bell
27a58a8962 Fix scientific notation for vapor pressures [skip ci] 2025-04-21 10:22:09 -04:00
Julien Marrec
6913fc41dc Format macros, they keep getting picked incrementally by clang format + Strip trailing whitespaces
```
find . -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx|py)$' | xargs -I@ sed -i 's/[ \t]*$//' "@"
```
2022-04-01 07:39:35 -04:00
ian
e72110bd65 Fix CP import 2019-11-09 13:24:34 -07:00
ian
9ce757a80b Fix delimiter 2019-11-08 21:22:37 -07:00
Ian Bell
3b1eb50324 More pep8 whitespace; see #1612 2019-01-12 20:45:25 -07:00
Ian Bell
8d131a2e59 More safe whitespace changes 2019-01-12 20:24:55 -07:00
Ian Bell
96483e04a8 Remove prints 2019-01-12 00:34:57 -07:00
Ian Bell
05bd19547b Some more 2->3 2019-01-12 00:34:24 -07:00
Ian Bell
f4bbb24471 Remove unused imports (besides they are Py 2.x only) 2019-01-11 22:34:24 -07:00
scls19fr
5045c96322 Fix Python print (#1746)
* Fix print

* Some manual fixes

* Revert
2018-10-19 22:59:31 +02:00
luzpaz
93f4a986e2 Misc. typos (#1726)
Found via `codespell -i 3 -w -I ../coolprop-word-whitelist.txt` whereby whitelist consists of:
```
cas
formate
hel
nd
te
tim
ue
uint
```
2018-08-14 23:06:49 -06:00
Matthis Thorade
19a4875879 More autopep8 (#1621)
* autopep8 rule-groups E101,W1,W2,W3

* autopep8 with rule group E3 (blank lines)

autopep8 --in-place --recursive --max-line-length=200 --exclude="externals" --select="E101,E3,W1,W2,W3" .

* tabs and space W191

* autopep8 aggressive
2017-12-13 14:43:41 +01:00
Matthis Thorade
526cb198a4 autopep8 whitespace (#1613)
* autopep8 whitespace only:

--select="E101,W1,W2"

* revert single file: web2py_online.py

Should this be a .py file at all?

* revert file Tickets/1443.py because the diff looked strange:

maybe there is an encoding problem?

* Rename web2py_online.py to web2py_online.rst
2017-12-12 08:32:38 -07:00
Ian Bell
f5eebdff5b Add InChI and friends to web pages; see #1069 2016-07-27 20:08:28 -06:00
Ian Bell
75d121d9fd Add acentric factor to web docs; see #1075 2016-05-22 13:03:01 +02:00
Ian Bell
194665adc0 Maybe this fixes multiple papers in the same category from #987 2016-03-12 22:16:23 -07:00
Ian Bell
e67fe66cd4 Allow for multiple bibtex keys in the docs; closes #932 2016-01-17 17:33:08 -07:00
Ian Bell
faa18cb9d1 Remove _{1} from formulas for the web 2015-11-14 22:11:07 -07:00
Ian Bell
e74044d496 Empty formulas (pseudo-pures for instance) show up as not applicable now 2015-04-26 16:58:52 -06:00
Ian Bell
d9d4541434 Add chemical formula to docs 2015-04-10 20:12:28 -06:00
Ian Bell
a2d54ccb44 Might have fixed encoding problems for escaped characters; See #577 2015-04-06 22:09:44 -06:00
Ian Bell
093622b8f1 Add surface tension and pc to docs - closes https://github.com/CoolProp/CoolProp/issues/314 and https://github.com/CoolProp/CoolProp/issues/302
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-12-08 18:45:34 -05:00
Ian Bell
98172399c1 Fix math, remove hyperlink to consistency plots
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-12-02 21:43:17 -05:00
Ian Bell
8fc1fac00e html should get converted to HTML in sphinx
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-12-02 21:30:02 -05:00
Ian Bell
6348d76ad7 Add references to generated fluid files and more docs for consistency plots
Closes https://github.com/CoolProp/CoolProp/issues/266

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-12-02 20:48:00 -05:00
Ian Bell
80c73c265b Add EOS limits to docs
Closes https://github.com/CoolProp/CoolProp/issues/267

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-12-02 11:44:00 -05:00
Ian Bell
173ee1b465 typo in docs
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-28 23:05:46 -05:00
Ian Bell
d4898c3963 Added consistency plots to expensive docs.
Closes https://github.com/CoolProp/CoolProp/issues/235

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-27 12:07:18 -05:00
Ian Bell
5cc3518b31 Fix ASHRAE call
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-24 12:49:19 -05:00
Ian Bell
7ebf29ad9d Fix the text for the scripts for REFPROP comparison plots
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-24 02:12:57 -05:00
Ian Bell
ae598b366d Add the comparison plots with REFPROP
See also https://github.com/CoolProp/CoolProp/issues/236

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-24 01:45:24 -05:00
Ian Bell
0228289b43 Fixed the number of columns for csv tables
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-17 18:57:17 -05:00
Ian Bell
cecfa7c0b6 Updated column widths for fluid info tables
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-17 18:04:18 -05:00
Ian Bell
73c580b901 Updated docs for fluid properties to remove bugs with rst not being in toc
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-17 17:39:38 -05:00
Ian Bell
9c4ca15c28 Added script to generate fluid information for web on the fly - just need plots now
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-10-14 13:55:10 +02:00
Jorrit Wronski
b5ba07be78 Reworked the documentation generator scripts and the binary mixture table 2014-09-26 18:32:50 +02:00