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

Fit ECIs manually #345

Open
sjtuzhanglei opened this issue Jan 5, 2024 · 3 comments
Open

Fit ECIs manually #345

sjtuzhanglei opened this issue Jan 5, 2024 · 3 comments

Comments

@sjtuzhanglei
Copy link

Dear CASM developers,

In the case that I want to modify the total energy at 0 K from DFT by, say, adding vibrational contribution, or any other type of corrections, and then fit the ECIs, what would be the easiest way to do that?

Should I do it completely separately from casm-learn functionalities, or try to modify some of the key input files that casm-learn uses (the energy part specifically)?

Thanks!

@bpuchala
Copy link
Contributor

bpuchala commented Jan 9, 2024

If you look at the casm learn --settings-format help for the "problem_specs"/"data" parameters, there are some options for specifying the input data. You could for instance add a new column to a "train" selection file and set "X": "new_column_name".

Alternatively, you can use any method you want to do the fitting and then use the Python function casm.project.write_eci to write the eci.json file.

@sjtuzhanglei
Copy link
Author

sjtuzhanglei commented Jan 13, 2024 via email

@sjtuzhanglei
Copy link
Author

Hi Brian,

I did what you said, but I got an error. Could you please help me on this?

{ "problem_specs": { "data": { "filename": "train.1.final_form_energy_sorted", "filetype": "selection", "X": "corr", "y": "final_formation_energy", "kwargs": null }, ......

# alias_or_name selected final_formation_energy SCEL1_1_1_1_0_0_0/0 1 0.0924656 SCEL1_1_1_1_0_0_0/1 1 0.1171833 SCEL1_1_1_1_0_0_0/2 1 0 SCEL1_1_1_1_0_0_0/3 1 -0.0417767 SCEL1_1_1_1_0_0_0/4 1 -0.0465267 SCEL1_1_1_1_0_0_0/5 1 -0.2006344 SCEL1_1_1_1_0_0_0/6 1 -0.0000511 SCEL1_1_1_1_0_0_0/7 0 ......

Loading fit_1_ga.json

Hall of Fame size: 10

Get problem data...

Traceback (most recent call last):
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 3790, in get_loc
return self._engine.get_loc(casted_key)
File "index.pyx", line 152, in pandas._libs.index.IndexEngine.get_loc
File "index.pyx", line 181, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 7080, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'selected'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/global/homes/v/voz5005/.local/conda/envs/casm/bin/casm-learn", line 8, in
sys.exit(main())
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/casm/scripts/casm_learn.py", line 212, in main
casm.learn.fit_and_select(input,
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/casm/learn/feature_selection.py", line 58, in fit_and_select
fdata = make_fitting_data(input,
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/casm/learn/fit.py", line 1589, in make_fitting_data
tdata = TrainingData(input, verbose=verbose)
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/casm/learn/fit.py", line 1401, in init
columns = [
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/casm/learn/fit.py", line 1403, in
if x not in sel.data.columns
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/casm/project/selection.py", line 117, in data
self._clean_data()
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/casm/project/selection.py", line 232, in _clean_data
self.astype('selected', bool)
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/casm/project/selection.py", line 228, in astype
columnname] = self._data.loc[:,
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/pandas/core/indexing.py", line 1147, in getitem
return self._getitem_tuple(key)
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/pandas/core/indexing.py", line 1330, in _getitem_tuple
return self._getitem_lowerdim(tup)
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/pandas/core/indexing.py", line 1039, in _getitem_lowerdim
section = self._getitem_axis(key, axis=i)
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/pandas/core/indexing.py", line 1393, in _getitem_axis
return self._get_label(key, axis=axis)
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/pandas/core/indexing.py", line 1343, in _get_label
return self.obj.xs(label, axis=axis)
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/pandas/core/generic.py", line 4222, in xs
return self[key]
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/pandas/core/frame.py", line 3893, in getitem
indexer = self.columns.get_loc(key)
File "/global/homes/v/voz5005/.local/conda/envs/casm/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 3797, in get_loc
raise KeyError(key) from err
KeyError: 'selected'

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