usnistgov / COSMOSAC

A Benchmark Implementation of COSMO-SAC
MIT License
51 stars 29 forks source link

Adding new sigma profile #20

Open Neverland-ss opened 2 years ago

Neverland-ss commented 2 years ago

Hi professor, thank you so much for sharing this amazing work. I am new to cmake. I want to add the sigma profile I calculate to cCOSMO and then use it for later calculation, but when I directly adding it to vt-2005 database, it will say wrong. So, I was wondering if I want to add new database, is that means I need to rewrite a code to make new cCOSMO module?

ianhbell commented 2 years ago

The sigma profiles should not be put in with the existing profiles, you should put them in another folder and change the paths accordingly. You should not need to recompile cCOSMO either.

Neverland-ss commented 2 years ago

Thank you for your reply! I have tried to put them in another folder and change the paths accordingly. I tried to add my database into profiles fold and change path to mine and run the testit.py in terminal. Like: dbVT = cCOSMO.VirginiaTechProfileDatabase( here+"/profiles/VT2005/MineDatabase/Sigma_Profile_Database.txt", here+"/profiles/VT2005/MineDatabase/Sigma_Profiles_v1/")

It says : dbVT = cCOSMO.VirginiaTechProfileDatabase( ValueError: Need at least 6 entries in line

Then, I tried to change cCOSMO.VirginiaTechProfileDatabase to cCOSMO.MineDatabase. Like: dbVT = cCOSMO.MineDatabase(here+"/profiles/MineDatabase/Sigma_Profile_Database.txt", here+"/profiles/MineDatabase/Sigma_Profiles_v1/") it says: AttributeError: module 'cCOSMO' has no attribute 'MineDatabase'.

I don't know why that would happen. Could you please help me with this problem. THANK YOU SO MUCH!

ianhbell commented 2 years ago

In pseudocode, you need something like this:

import cCOSMO
db = cCOSMO.VirginiaTechProfileDatabase(
"myVT2005/Sigma_Profile_Database.txt",
"myVT2005/Sigma_Profiles/")

where you make the Sigma_Profile_Database.txt in the same format as the original, and put your profile in the folder Sigma_Profiles

Neverland-ss commented 2 years ago

Thank you so much for your kindness reply! I do change the code like this: import cCOSMO here = os.path.abspath(os.path.dirname(__file__)) dbVT = cCOSMO.VirginiaTechProfileDatabase( here+ "/profiles/VT2005/Sigma_Profile_Database_Index_v1.txt", here+ "/profiles/VT2005/Sigma_Profiles_v1/") And for the folder, I add it to VT2005 and make a new txt in the same format as the original.

截屏2022-03-28 上午10 08 01

Unfortunately, it still give me this hit: in dbVT = cCOSMO.VirginiaTechProfileDatabase( ValueError: Need at least 6 entries in line. Also, create a new folder as VT2005 would have the same problem.

ianhbell commented 2 years ago

What are the contents of your Sigma_Profile_Database_Index_v1.txt and your sigma profile?

Neverland-ss commented 2 years ago

For Sigma_Profile_Database_Index_v1, because I want to calculate some not existing chemical compounds, so some information like cas, cosmo segments ...were just made up.

截屏2022-03-28 下午8 42 36

For sigma profile, I use the fortran program provided by VT group.

截屏2022-03-28 下午8 43 23
ianhbell commented 2 years ago

The metadata file needs to be in the same exact format as the original. Are you missing the last column?

Neverland-ss commented 2 years ago
截屏2022-03-28 下午9 04 33

Actually, I think they are the same. I copy it directly from the original one.

ianhbell commented 2 years ago

Can you please attach your file? I think the delimiters might be wrong

ianhbell commented 2 years ago

And please attach one of your sigma profiles, I want to test on my side.

Neverland-ss commented 2 years ago

Sigma_Profile_Database_Index_v1.txt my-0001-PROF.txt my-0002-PROF.txt my-0003-PROF.txt my-0004-PROF.txt Sorry, I add it here. you so much!

ianhbell commented 2 years ago

First problem: your metadata file doesn't use tabs for the delimiter, you have to use the same format Second problem: your sigma profile file uses tabs, not spaces

Neverland-ss commented 2 years ago

I see! I will try again. Thank you sooooo much!

ianhbell commented 2 years ago

Also, you need a single delimiter in all cases

ianhbell commented 2 years ago

Once you get that sorted, you want something like:

import cCOSMO
names = ['C1H1']
db = cCOSMO.VirginiaTechProfileDatabase(
    "profiles/VT2005test/Sigma_Profile_Database_Index_v1.txt",
    "profiles/VT2005test/")

# Add the fluids we want into the database
for name in names:
    iden = db.normalize_identifier(name)
    print(iden)
    db.add_profile(iden)
COSMO = cCOSMO.COSMO1(names, db)
T = 300
composition = [0.5, 0.5]

print(COSMO.get_lngamma_comb(T, composition) + COSMO.get_lngamma_resid(T, composition))
Neverland-ss commented 2 years ago

This works!!! Thank you a lot!

Neverland-ss commented 2 years ago

Hello, Professor. I got another problem, would you please give me some help?

I want to add some new sigma profiles, and I got stuck at the file format:

  1. the sigma profile txt has two colums, I check your example and I find they have to be 22 sels, is it correct?
  2. each colums seems to be right-justified, is it correct?
  3. there are two sels between the two columns, is it correct?

Waiting for your reply. Sorry for asking for help again.

ianhbell commented 2 years ago
  1. Yes, but it doesn't matter, so long as C++ will convert to to double
  2. Yes, but it doesn't matter
  3. Are you sure? For instance this only has one: https://github.com/usnistgov/COSMOSAC/blob/master/profiles/UD/sigma3/AATNZNJRDOVKDD-UHFFFAOYSA-N.sigma
Neverland-ss commented 2 years ago

I figured it out. Thank you so much!!