Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieving list of all components #36

Closed
dhkblaszyk opened this issue Jan 25, 2021 · 1 comment
Closed

Retrieving list of all components #36

dhkblaszyk opened this issue Jan 25, 2021 · 1 comment

Comments

@dhkblaszyk
Copy link

I have searched but was unable to find a method that retrieved a full list of components in the database at runtime. I would also like to iterate through the available physical property models for each of the components, including the validity ranges (T & P). The reason for asking is that I am working on a graphical front end and would like to show this information to the user.

@yoelcortes
Copy link
Member

It's not elegant, but here is one way to do it:

from thermosteam import Chemical # Load thermosteam first to implement pubchem_db.search method
from chemicals.identifiers import pubchem_db  # Chemical metadata manager
try: pubchem_db.search('badname') # Autoloads all metadata files
except: pass
all_chemicals = [Chemical(i.CASs) for i in pubchem_db.CAS_index.values()] 
# Note that len(all_chemicals) == 74191, so your ram is going to suffer with list comprehension
# You might want to use a generator instead

Only about 20,000 chemicals have any information other than the chemical metadata (names and molecular weight).
Although most T and P domains are by the book, some are a little arbitrary... suggestions are welcome :)

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants