Comments (3)
Hi Jeff,
This one I believe is a limitation of numba's vectorize function. The scalar form works fine:
from chemicals import numba
import numpy as np
numba.Lindsay_Bromley(333.0, np.array([0.2, 0.8]), np.array([1.0, 1.0]), np.array([1.0, 1.0]), np.array([351.0, 370.0]), np.array([18.0, 33.0]))
The broadcasting rules aren't quite all implemented in Numba. I have known about this issue for a while but haven't ran into it before. I will need to look into this one. It may be possible to implement some sort of a wrapper.
Sincerely.
Caleb
from chemicals.
Am I misunderstanding how a mixing rule is meant to work? I have two components and want want the mixture value for a range of compositions, so I would need to pass ys = [ [x1, x2, ...], [y1, y2, ...]]
. Since I'm passing in a range of compositions, I should also be able to pass in a range for the other props too, correct? The way you've written it above, I can only use this function for a single composition ([x1, y1] = [0.2, 0.2]
).
from chemicals.
Hi Jeff,
Numba is very magic but it isn't smart enough to know how to pass in the compositions, thermal conductivities, and viscositires to the inner loop. Should it vectorize by passing in ys=[x1, x2] or ys=[x1, y1]? It can't tell and there isn't a set of hard-coded assumptions for this case. In a case like this, there is a mechanism to manually specify how to do this calculation:
import chemicals.numba
import numpy as np
from numba import guvectorize
from numba.types import int64, float64
@guvectorize([(float64[:], float64[:, :], float64[:, :],
float64[:, :], float64[:], float64[:], float64[:])], '(n),(n,n),(n,n),(n,n),(n),(n)->(n)')
def better_Lindsay_Bromley(T, ys, ks, mus, Tbs, MWs, res):
for i in range(T.shape[0]):
res[i] = chemicals.numba.Lindsay_Bromley(T[i], ys[:, i], ks[:, i], mus[:, i], Tbs, MWs)
better_Lindsay_Bromley(np.array([333.0, 334.0]), np.array([[0.2, 0.2], [0.8, 0.8]]), np.array([[1, 1], [1,1]]),
np.array([[1, 1], [1, 1]]), np.array([351.0, 370.0]), np.array([18.0, 33.0]))
array([0.9969455 , 0.99694497])
I don't have a clear idea how to implement this in the library as a whole at this time, but it is a topic I am interested in for sure.
In the future numba may have better support for doing this automatically. For example the error you received originally is clearly not applicable in this case.
from chemicals.
Related Issues (20)
- identifiers.py HOT 1
- Heat capacity functions by mol HOT 3
- DIPPR 801 2019? HOT 1
- conda-forge Package Missing HOT 5
- Update GWPs for IPCC Report version 5 HOT 2
- Pandas' new high-precision csv float parser is sometimes quite low precision HOT 1
- Problem with Antoine's coefficients for Toluene HOT 1
- The vectorized submodule is not fully supported throughout the package HOT 6
- incorrect separators on water synonyms HOT 7
- Incorrect calculation of density when using saturation temperature as input HOT 2
- Get chemical name from chemical notation HOT 3
- GWP IPCC 5th edition (2018)
- Nitrogen Lennard-Jones values missing HOT 2
- Searching for CO returns methanol. HOT 2
- Vs in COSTALD_compressed should be Vsat?
- Many chemicals input are found but no data given
- Incorrect formula for dichlorosilane and trichlorosilane
- `TypeError` when operating in no-JIT mode HOT 2
- Steam density calculations change significantly with new release HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chemicals.