Skip to content

Commit

Permalink
Merge pull request #353 from usnistgov/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
knc6 authored Jan 16, 2025
2 parents 2a3c3bb + c5c860a commit 922939a
Show file tree
Hide file tree
Showing 308 changed files with 1,608 additions and 70,544 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

# Create logs directory if it doesn't exist
mkdir -p logs

jid_list=('JVASP-62940' 'JVASP-20092')
#jid_list=('JVASP-1002')
# Define arrays of JIDs and calculators
#jid_list=('JVASP-1002' 'JVASP-890' 'JVASP-39' 'JVASP-30' 'JVASP-62940' 'JVASP-20092' 'JVASP-8003' 'JVASP-1192' 'JVASP-23' 'JVASP-1195' 'JVASP-96' 'JVASP-10591' 'JVASP-1198' 'JVASP-1312' 'JVASP-133719' 'JVASP-36873' 'JVASP-1327' 'JVASP-1372' 'JVASP-1408' 'JVASP-8184' 'JVASP-1174' 'JVASP-1177' 'JVASP-1180' 'JVASP-1183' 'JVASP-1186' 'JVASP-1189' 'JVASP-91' 'JVASP-8158' 'JVASP-8118' 'JVASP-107' 'JVASP-36018' 'JVASP-36408' 'JVASP-105410' 'JVASP-36403' 'JVASP-1008' 'JVASP-95268' 'JVASP-21211' 'JVASP-1023' 'JVASP-7836' 'JVASP-9166' 'JVASP-1201' 'JVASP-85478' 'JVASP-1115' 'JVASP-1112' 'JVASP-1103' 'JVASP-1109' 'JVASP-131' 'JVASP-149916' 'JVASP-111005' 'JVASP-25' 'JVASP-1067' 'JVASP-154954' 'JVASP-59712' 'JVASP-10703' 'JVASP-1213' 'JVASP-19007' 'JVASP-10114' 'JVASP-9175' 'JVASP-104' 'JVASP-10036' 'JVASP-18983' 'JVASP-1216' 'JVASP-79522' 'JVASP-1222' 'JVASP-10037' 'JVASP-110' 'JVASP-8082' 'JVASP-1240' 'JVASP-51480' 'JVASP-29539' 'JVASP-54' 'JVASP-29556' 'JVASP-1915' 'JVASP-75662' 'JVASP-101764' 'JVASP-22694' 'JVASP-4282' 'JVASP-76195' 'JVASP-8554' 'JVASP-149871' 'JVASP-2376' 'JVASP-14163' 'JVASP-26248' 'JVASP-18942' 'JVASP-3510' 'JVASP-5224' 'JVASP-8559' 'JVASP-85416' 'JVASP-9117' 'JVASP-90668' 'JVASP-10689' 'JVASP-106381' 'JVASP-108773' 'JVASP-101184' 'JVASP-103127' 'JVASP-104764' 'JVASP-102336' 'JVASP-110231' 'JVASP-108770' 'JVASP-101074' 'JVASP-149906' 'JVASP-99732' 'JVASP-106686' 'JVASP-110952' 'JVASP-106363' 'JVASP-972' 'JVASP-825' 'JVASP-813' 'JVASP-816' 'JVASP-802' 'JVASP-1029' 'JVASP-861' 'JVASP-943' 'JVASP-963' 'JVASP-14616' 'JVASP-867' 'JVASP-14968' 'JVASP-14970' 'JVASP-19780' 'JVASP-9147' 'JVASP-34249' 'JVASP-43367' 'JVASP-113' 'JVASP-41' 'JVASP-58349' 'JVASP-34674' 'JVASP-34656' 'JVASP-34249' 'JVASP-32')
calculator_types=("alignn_ff_12_2_24")
jid_list=('JVASP-1002' 'JVASP-890' 'JVASP-39' 'JVASP-30' 'JVASP-62940' 'JVASP-20092' 'JVASP-8003' 'JVASP-1192' 'JVASP-23' 'JVASP-1195' 'JVASP-96' 'JVASP-10591' 'JVASP-1198' 'JVASP-1312' 'JVASP-133719' 'JVASP-36873' 'JVASP-1327' 'JVASP-1372' 'JVASP-1408' 'JVASP-8184' 'JVASP-1174' 'JVASP-1177' 'JVASP-1180' 'JVASP-1183' 'JVASP-1186' 'JVASP-1189' 'JVASP-91' 'JVASP-8158' 'JVASP-8118' 'JVASP-107' 'JVASP-36018' 'JVASP-36408' 'JVASP-105410' 'JVASP-1008' 'JVASP-21211' 'JVASP-1023' 'JVASP-7836' 'JVASP-9166' 'JVASP-1201' 'JVASP-85478' 'JVASP-1115' 'JVASP-1112' 'JVASP-1103' 'JVASP-1109' 'JVASP-131' 'JVASP-149916' 'JVASP-111005' 'JVASP-25' 'JVASP-1067' 'JVASP-10703' 'JVASP-104' 'JVASP-10036' 'JVASP-18983' 'JVASP-1216' 'JVASP-79522' 'JVASP-1222' 'JVASP-10037' 'JVASP-110' 'JVASP-8082' 'JVASP-1240' 'JVASP-29539' 'JVASP-54' 'JVASP-1915' 'JVASP-22694' 'JVASP-4282' 'JVASP-76195' 'JVASP-8554' 'JVASP-149871' 'JVASP-2376' 'JVASP-3510' 'JVASP-5224' 'JVASP-8559' 'JVASP-85416' 'JVASP-9117' 'JVASP-90668' 'JVASP-103127' 'JVASP-104764' 'JVASP-110231' 'JVASP-108770' 'JVASP-149906' 'JVASP-99732' 'JVASP-106686' 'JVASP-106363' 'JVASP-972' 'JVASP-825' 'JVASP-813' 'JVASP-816' 'JVASP-802' 'JVASP-1029' 'JVASP-861' 'JVASP-943' 'JVASP-963' 'JVASP-14616' 'JVASP-867' 'JVASP-14968' 'JVASP-14970' 'JVASP-19780' 'JVASP-9147' 'JVASP-34249' 'JVASP-43367' 'JVASP-113' 'JVASP-41' 'JVASP-58349' 'JVASP-34674' 'JVASP-34249' 'JVASP-32')
calculator_types=("mace")

# Loop through each JID and calculator combination
for jid in "${jid_list[@]}"; do
Expand Down Expand Up @@ -46,27 +45,18 @@ cat > input_${jid}_${calculator}.json <<JSON
"constant_volume": false
}
},
"calculator_settings": {
"matgl": {
"model": "M3GNet-MP-2021.2.8-PES"
},
"alignn_ff": {
"stress_weight": 0.3
},
"chgnet": {}
},
"phonon_settings": {
"dim": [2, 2, 2],
"distance": 0.2
},
"use_conventional_cell": false,
"surface_settings": {
"indices_list": [
[1, 0, 0],
[1, 1, 1],
[1, 1, 0],
[0, 1, 1],
[0, 0, 1],
[1, 0, 0],
[1, 1, 1],
[1, 1, 0],
[0, 1, 1],
[0, 0, 1],
[0, 1, 0]
],
"layers": 4,
Expand Down
298 changes: 298 additions & 0 deletions jarvis_leaderboard/contributions/alignn_ff/run_chipsff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
#!/usr/bin/env python
import os
import pandas as pd
import plotly.express as px
import argparse
from jarvis.db.jsonutils import loadjson
from chipsff.config import CHIPSFFConfig
from tqdm import tqdm
from chipsff.general_material_analyzer import MaterialsAnalyzer
from chipsff.alignn_ff_db_analyzer import AlignnFFForcesAnalyzer
from chipsff.mlearn_db_analyzer import MLearnForcesAnalyzer
from chipsff.mptraj_analyzer import MPTrjAnalyzer
from chipsff.scaling_analyzer import ScalingAnalyzer


def analyze_multiple_structures(
jid_list, calculator_types, chemical_potentials_file, **kwargs
):
"""
Analyzes multiple structures with multiple calculators and aggregates error metrics.
Args:
jid_list (List[str]): List of JIDs to analyze.
calculator_types (List[str]): List of calculator types to use.
chemical_potentials_file (str): Path to the chemical potentials JSON file.
**kwargs: Additional keyword arguments for analysis settings.
Returns:
None
"""
composite_error_data = {}

for calculator_type in calculator_types:
# List to store individual error DataFrames
error_dfs = []

for jid in tqdm(jid_list, total=len(jid_list)):
print(f"Analyzing {jid} with {calculator_type}...")
# Fetch calculator-specific settings
calc_settings = kwargs.get("calculator_settings", {}).get(
calculator_type, {}
)
analyzer = MaterialsAnalyzer(
jid=jid,
calculator_type=calculator_type,
chemical_potentials_file=chemical_potentials_file,
bulk_relaxation_settings=kwargs.get(
"bulk_relaxation_settings"
),
phonon_settings=kwargs.get("phonon_settings"),
properties_to_calculate=kwargs.get("properties_to_calculate"),
use_conventional_cell=kwargs.get(
"use_conventional_cell", False
),
surface_settings=kwargs.get("surface_settings"),
defect_settings=kwargs.get("defect_settings"),
phonon3_settings=kwargs.get("phonon3_settings"),
md_settings=kwargs.get("md_settings"),
calculator_settings=calc_settings, # Pass calculator-specific settings
)
# Run analysis and get error data
error_dat = analyzer.run_all()
error_df = pd.DataFrame([error_dat])
error_dfs.append(error_df)

# Concatenate all error DataFrames
all_errors_df = pd.concat(error_dfs, ignore_index=True)

# Compute composite errors by ignoring NaN values
composite_error = all_errors_df.mean(skipna=True).to_dict()

# Store the composite error data for this calculator type
composite_error_data[calculator_type] = composite_error

# Once all materials and calculators have been processed, create a DataFrame
composite_df = pd.DataFrame(composite_error_data).transpose()

# Plot the composite scorecard
plot_composite_scorecard(composite_df)

# Save the composite dataframe
composite_df.to_csv("composite_error_data.csv", index=True)


def analyze_multiple_interfaces(
film_jid_list,
substrate_jid_list,
calculator_types,
chemical_potentials_file,
film_index="1_1_0",
substrate_index="1_1_0",
):
for calculator_type in calculator_types:
for film_jid in film_jid_list:
for substrate_jid in substrate_jid_list:
print(
f"Analyzing interface between {film_jid} and {substrate_jid} with {calculator_type}..."
)
analyzer = MaterialsAnalyzer(
calculator_type=calculator_type,
chemical_potentials_file=chemical_potentials_file,
film_jid=film_jid,
substrate_jid=substrate_jid,
film_index=film_index,
substrate_index=substrate_index,
)
analyzer.analyze_interfaces()


def plot_composite_scorecard(df):

fig = px.imshow(
df, text_auto=True, aspect="auto", labels=dict(color="Error")
)

# Update layout for larger font sizes
fig.update_layout(
font=dict(size=24), # Adjust the font size
coloraxis_colorbar=dict(
title_font=dict(size=18), tickfont=dict(size=18)
),
)

# Optionally adjust the text font size for cells
fig.update_traces(textfont=dict(size=18)) # Adjust text size in cells
fname_plot = "composite_error_scorecard.png"
fig.write_image(fname_plot)
fig.show()


# Ensure that the necessary modules and functions are imported
# from your existing codebase, such as `data`, `Atoms`, `voigt_6_to_full_3x3_stress`, etc.
# Example:
# from your_module import data, Atoms, voigt_6_to_full_3x3_stress, loadjson


def main():
import pprint

parser = argparse.ArgumentParser(description="Run Materials Analyzer")
parser.add_argument(
"--input_file",
default="input.json",
type=str,
help="Path to the input configuration JSON file",
)
args = parser.parse_args()

input_file = loadjson(args.input_file)
input_file_data = CHIPSFFConfig(**input_file)
pprint.pprint(input_file_data.dict())

# Check if scaling test is requested
if input_file_data.scaling_test:
print("Running scaling test...")
scaling_analyzer = ScalingAnalyzer(input_file_data)
scaling_analyzer.run()
else:
# Determine the list of JIDs
if input_file_data.jid:
jid_list = [input_file_data.jid]
elif input_file_data.jid_list:
jid_list = input_file_data.jid_list
else:
jid_list = []

# Determine the list of calculators
if input_file_data.calculator_type:
calculator_list = [input_file_data.calculator_type]
elif input_file_data.calculator_types:
calculator_list = input_file_data.calculator_types
else:
calculator_list = []

# Handle film and substrate IDs for interface analysis
film_jids = input_file_data.film_id if input_file_data.film_id else []
substrate_jids = (
input_file_data.substrate_id
if input_file_data.substrate_id
else []
)

# Scenario 5: Batch Processing for Multiple JIDs and Calculators
if input_file_data.jid_list and input_file_data.calculator_types:
analyze_multiple_structures(
jid_list=input_file_data.jid_list,
calculator_types=input_file_data.calculator_types,
chemical_potentials_file=input_file_data.chemical_potentials_file,
bulk_relaxation_settings=input_file_data.bulk_relaxation_settings,
phonon_settings=input_file_data.phonon_settings,
properties_to_calculate=input_file_data.properties_to_calculate,
use_conventional_cell=input_file_data.use_conventional_cell,
surface_settings=input_file_data.surface_settings,
defect_settings=input_file_data.defect_settings,
phonon3_settings=input_file_data.phonon3_settings,
md_settings=input_file_data.md_settings,
calculator_settings=input_file_data.calculator_settings, # Pass calculator-specific settings
)
else:
# Scenario 1 & 3: Single or Multiple JIDs with Single or Multiple Calculators
if jid_list and tqdm(calculator_list, total=len(calculator_list)):
for jid in tqdm(jid_list, total=len(jid_list)):
for calculator_type in calculator_list:
print(f"Analyzing {jid} with {calculator_type}...")
# Fetch calculator-specific settings
calc_settings = (
input_file_data.calculator_settings.get(
calculator_type, {}
)
)
analyzer = MaterialsAnalyzer(
jid=jid,
calculator_type=calculator_type,
chemical_potentials_file=input_file_data.chemical_potentials_file,
bulk_relaxation_settings=input_file_data.bulk_relaxation_settings,
phonon_settings=input_file_data.phonon_settings,
properties_to_calculate=input_file_data.properties_to_calculate,
use_conventional_cell=input_file_data.use_conventional_cell,
surface_settings=input_file_data.surface_settings,
defect_settings=input_file_data.defect_settings,
phonon3_settings=input_file_data.phonon3_settings,
md_settings=input_file_data.md_settings,
calculator_settings=calc_settings, # Pass calculator-specific settings
)
analyzer.run_all()

# Proceed with other scenarios that don't overlap with jid_list and calculator_types
# Scenario 2 & 4: Interface Calculations (Multiple Calculators and/or JIDs)
if film_jids and substrate_jids and calculator_list:
for film_jid, substrate_jid in zip(film_jids, substrate_jids):
for calculator_type in calculator_list:
print(
f"Analyzing interface between {film_jid} and {substrate_jid} with {calculator_type}..."
)
# Fetch calculator-specific settings
calc_settings = input_file_data.calculator_settings.get(
calculator_type, {}
)
analyzer = MaterialsAnalyzer(
calculator_type=calculator_type,
chemical_potentials_file=input_file_data.chemical_potentials_file,
film_jid=film_jid,
substrate_jid=substrate_jid,
film_index=input_file_data.film_index,
substrate_index=input_file_data.substrate_index,
bulk_relaxation_settings=input_file_data.bulk_relaxation_settings,
phonon_settings=input_file_data.phonon_settings,
properties_to_calculate=input_file_data.properties_to_calculate,
calculator_settings=calc_settings, # Pass calculator-specific settings
)
analyzer.analyze_interfaces()

# Continue with other independent scenarios
# Scenario 6: MLearn Forces Comparison
if input_file_data.mlearn_elements and input_file_data.calculator_type:
print(
f"Running mlearn forces comparison for elements {input_file_data.mlearn_elements} with {input_file_data.calculator_type}..."
)
mlearn_analyzer = MLearnForcesAnalyzer(
calculator_type=input_file_data.calculator_type,
mlearn_elements=input_file_data.mlearn_elements,
calculator_settings=input_file_data.calculator_settings.get(
input_file_data.calculator_type, {}
),
)
mlearn_analyzer.run()

# Scenario 7: AlignnFF Forces Comparison
if input_file_data.alignn_ff_db and input_file_data.calculator_type:
print(
f"Running AlignnFF forces comparison with {input_file_data.calculator_type}..."
)
alignn_ff_analyzer = AlignnFFForcesAnalyzer(
calculator_type=input_file_data.calculator_type,
num_samples=input_file_data.num_samples,
calculator_settings=input_file_data.calculator_settings.get(
input_file_data.calculator_type, {}
),
)
alignn_ff_analyzer.run()

# Scenario 8: MPTrj Forces Comparison
if input_file_data.mptrj and input_file_data.calculator_type:
print(
f"Running MPTrj forces comparison with {input_file_data.calculator_type}..."
)
mptrj_analyzer = MPTrjAnalyzer(
calculator_type=input_file_data.calculator_type,
num_samples=input_file_data.num_samples,
calculator_settings=input_file_data.calculator_settings.get(
input_file_data.calculator_type, {}
),
)
mptrj_analyzer.run()


if __name__ == "__main__":
main()
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 0 additions & 15 deletions jarvis_leaderboard/contributions/alignn_ff_12_2_24/metadata.json

This file was deleted.

Loading

0 comments on commit 922939a

Please sign in to comment.