Skip to content

Error in band_gap_example #1

@jinwoolee29

Description

@jinwoolee29

Hello,
I have a question about the band_gap_example.ipynb file in LLMatDesign.

When running band_gap_example.ipynb, an AttributeError occurs related to MDLCalculator.

The MatDeepLearn_dev environment has been fully installed, and the path to the best_checkpoint.pt file in the checkpoint folder's config.yml file has been correctly set. Additionally, the Material Project API key was initially missing, but I have updated it. After running the notebook, the following error message is displayed:

AttributeError: 'MDLCalculator' object has no attribute 'direct_calculate'

Using the dir function to inspect the modules implemented in MDLCalculator, it seems that the issue is caused by the absence of direct_calculate.

I would greatly appreciate it if you could provide guidance on resolving this issue.

Below are the full details of the error message. Thank you.


AttributeError Traceback (most recent call last)
Cell In[8], line 16
5 llm = AskLLM("gpt-4o", api_key=api_key, openai_organization=openai_organization)
7 agent = Agent(
8 llm,
9 save_path="outputs/cifs/",
(...)
13 mp_api_key=mp_api_key
14 )
---> 16 out = discover_bandgap(
17 agent,
18 chemical_formula="SrTiO3"
19 )

File C:\MatDeepLearn_dev\LLMatDesign\llmatdesign\core\discover.py:46, in discover_bandgap(agent, chemical_formula, structure, band_gap, target_value, max_iterations)
43 modification_str = get_action(agent.llm, prompt)
44 modification = ast.literal_eval(modification_str)
---> 46 new_structure, new_band_gap = agent.perform_modification(
47 structures_list[-1],
48 modification["Modification"],
49 calculation_type='band_gap'
50 )
52 # get post action reflection
53 reflection_prompt = get_reflection_prompt(
54 structures_list[-1].get_chemical_formula('metal'),
55 new_structure.get_chemical_formula('metal'),
(...)
59 new_band_gap
60 )

File C:\MatDeepLearn_dev\LLMatDesign\llmatdesign\core\agent.py:232, in Agent.perform_modification(self, structure, modification, calculation_type)
229 else:
230 raise ValueError(f"Invalid modification type: {modification_type}")
--> 232 return self.optimize_and_calculate(new_structure, calculation_type=calculation_type)

File C:\MatDeepLearn_dev\LLMatDesign\llmatdesign\core\agent.py:159, in Agent.optimize_and_calculate(self, atoms, calculation_type)
157 return optimized_atoms[0], val
158 elif calculation_type == "band_gap" and self.bandgap_calculator is not None:
--> 159 val = self.bandgap_calculator.direct_calculate(optimized_atoms[0])
160 return optimized_atoms[0], val
161 else:

AttributeError: 'MDLCalculator' object has no attribute 'direct_calculate'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions