Email (Optional)
rahma103@purdue.edu
Problem
I’m currently using CHGNet and have a question about comparing DFT and CHGNet predictions for forces and energy. I’d like to create a parity plot between DFT-calculated forces/energies and CHGNet-predicted values. Could you advise on the best way to extract the DFT and predicted forces and energies from the model output? Any tips on creating a well-structured parity plot would be greatly appreciated!
Proposed Solution
dft_forces = []
ml_forces = []
for batch in test_loader:
structures, target_data = batch
target_forces = np.array(target_data['f'])
# Predict forces with the trained model
predicted_output = chgnet(structures) # Get model output as a dictionary
predicted_forces = np.array(predicted_output['f']) # Extract forces directly
dft_forces.extend(target_forces.flatten())
ml_forces.extend(predicted_forces.flatten())
Convert to numpy arrays for plotting
dft_forces = np.array(dft_forces)
ml_forces = np.array(ml_forces)
Plot DFT vs. ML-predicted forces
plt.figure(figsize=(6, 6))
plt.scatter(dft_forces, ml_forces, alpha=0.5, marker='o')
plt.plot([dft_forces.min(), dft_forces.max()], [dft_forces.min(), dft_forces.max()], 'k--', lw=2)
plt.xlabel("DFT Forces (eV/Å)")
plt.ylabel("ML Predicted Forces (eV/Å)")
plt.title("Comparison of DFT vs. ML Predicted Forces")
plt.grid(True)
plt.show()
Alternatives
No response
Code of Conduct
Email (Optional)
rahma103@purdue.edu
Problem
I’m currently using CHGNet and have a question about comparing DFT and CHGNet predictions for forces and energy. I’d like to create a parity plot between DFT-calculated forces/energies and CHGNet-predicted values. Could you advise on the best way to extract the DFT and predicted forces and energies from the model output? Any tips on creating a well-structured parity plot would be greatly appreciated!
Proposed Solution
dft_forces = []
ml_forces = []
for batch in test_loader:
structures, target_data = batch
target_forces = np.array(target_data['f'])
Convert to numpy arrays for plotting
dft_forces = np.array(dft_forces)
ml_forces = np.array(ml_forces)
Plot DFT vs. ML-predicted forces
plt.figure(figsize=(6, 6))
plt.scatter(dft_forces, ml_forces, alpha=0.5, marker='o')
plt.plot([dft_forces.min(), dft_forces.max()], [dft_forces.min(), dft_forces.max()], 'k--', lw=2)
plt.xlabel("DFT Forces (eV/Å)")
plt.ylabel("ML Predicted Forces (eV/Å)")
plt.title("Comparison of DFT vs. ML Predicted Forces")
plt.grid(True)
plt.show()
Alternatives
No response
Code of Conduct