Comments (6)
from chempy.
Thanks, I think I understand the issues.
Would requiring the user to use some kind of special notation for decimal subscripts potentially help with the hydrates issue?
E.g. putting the subscript in square brackets or curly braces?
'Ca{2.832}Fe{0.6285}Mg{2.5395}(CO3)6'
from chempy.
from chempy.
Awesome, thanks!
I wish I could help more, but I don't think I would be that much help to you at this point.
from chempy.
For anyone else needing to work with decimal subscripts, here is a function to quickly calculate the smallest integer subscripts, and the scaling factor.
import decimal
def integer_subs(frac_subs):
dec = [decimal.Decimal(str(sub)).as_tuple().exponent for sub in frac_subs]
decmin = min(dec)
mf = 10**-decmin
subs = frac_subs*mf
subs = subs.round()
subs = subs.astype(int)
cd = gcd.reduce(subs)
subsf = (subs/cd).astype(int)
print('Integer Subscripts: ', subsf)
sf = mf/cd
print('Scaling Factor:', sf)
subs1 = np.array([2.832,0.6285,2.5395,6])
integer_subs(subs1)
Integer Subscripts: [1888 419 1693 4000]
Scaling Factor: 666.6666666666666
from chempy.
Hi, and thank you both for looking into this.
I'm open to changing the syntax for crystal water to allow parsing non-integer stoichiometric coefficients.
What about "Na2SO4:10H2O", does that look "natural" enough in your eyes? (just a spontaneous suggestion of mine).
I personally won't be able to code up a prototype anytime soon I'm afraid, but if you want to go ahead I'll definitely make time for code review and publishing an updated release etc.
Changing the syntax will be a breaking change, so we'll need to bump the version number, ideally one could have the parser accept both old and new syntax for one intermediate release, issuing a warning instructing the user to migrate to the new syntax. But if that is not possible I'm open to skipping the deprecation cycle.
from chempy.
Related Issues (20)
- Equilibrium root fails with water & co2-hydrolysis test
- Interest in chemical group theory component? HOT 3
- 7 tests fail on FreeBSD HOT 2
- Could this package be used to solve steam reforming problems?
- Interpreting malformed chemical formulas as substances HOT 32
- Suggestion: Funding coding or documentation through Google Summer of Code or Season of Docs HOT 1
- Please fill out SymPy documentation theme survey
- Test ChemPy with SymPy 1.10rc2 HOT 1
- Update README for improved chemical formula parser HOT 8
- New release? HOT 1
- Issue with Balancing Reactions (from examples) HOT 3
- FYI: ChemPy mentioned in Talk Python to Me podcast HOT 1
- Balancing reactions with non-integer stoichiometry HOT 1
- Two pytests are failing in our GitHub Action HOT 3
- Chempy documentation issues HOT 4
- Installation Errors HOT 1
- Give two dict() in chemstry.Reaction() not work HOT 5
- 5 tests fail HOT 2
- Zn(NO3)2.6H2O fails to parse in 0.8.3, regression? HOT 9
- New numpy error on import HOT 6
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 chempy.