{"id":44558,"library":"chgnet","title":"CHGNet","description":"CHGNet (Charge-informed Graph Neural Network) is a pretrained universal neural network potential for charge-informed atomistic modeling. Version 0.4.2 supports Python >=3.10 and provides models for energy, forces, stresses, and charge predictions. Released under the CederGroupHub.","status":"active","version":"0.4.2","language":"python","source_language":"en","source_url":"https://github.com/CederGroupHub/chgnet","tags":["neural-network-potential","atomistic","charge-informed","universal-potential","materials-science"],"install":[{"cmd":"pip install chgnet","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for model inference","package":"torch","optional":false},{"reason":"Structure object handling","package":"pymatgen","optional":false},{"reason":"Alternative structure/converter","package":"ase","optional":true}],"imports":[{"note":"CHGNetCalculator is in chgnet.model submodule.","wrong":"from chgnet import CHGNetCalculator","symbol":"CHGNetCalculator","correct":"from chgnet.model import CHGNetCalculator"},{"note":"CHGNet class is in chgnet.model.","wrong":"from chgnet import CHGNet","symbol":"CHGNet","correct":"from chgnet.model import CHGNet"},{"note":"Correct import for pymatgen Structure.","wrong":"","symbol":"Structure","correct":"from pymatgen.core import Structure"}],"quickstart":{"code":"from chgnet.model import CHGNet, CHGNetCalculator\nfrom pymatgen.core import Structure\nimport numpy as np\n\n# Load pretrained model\nchgnet = CHGNet.load()\n\n# Create a simple structure (e.g., diamond cubic Si)\nlattice = [[0, 2.73, 2.73], [2.73, 0, 2.73], [2.73, 2.73, 0]]\nspecies = ['Si', 'Si']\ncoords = [[0, 0, 0], [1.365, 1.365, 1.365]]\nstructure = Structure(lattice, species, coords)\n\n# Create calculator and compute\ncalculator = CHGNetCalculator(chgnet)\nstructure.calc = calculator\nenergy = structure.get_potential_energy()\nforces = structure.get_forces()\nmagmoms = structure.get_magnetic_moments()\nprint(f\"Energy: {energy:.4f} eV\")\nprint(f\"Forces: {forces}\")","lang":"python","description":"Quickstart: Load pretrained CHGNet model, create a pymatgen Structure, and compute energy/forces/magmoms."},"warnings":[{"fix":"Update imports: use 'chgnet.model' and 'chgnet.data' instead of 'chgnet.graph'.","message":"CHGNet version 0.4.0 changed the model directory structure and removed the old 'chgnet.graph' module.","severity":"breaking","affected_versions":"<=0.3.x to 0.4.x"},{"fix":"Verify that the pymatgen Structure is in Angstroms (default) or convert using structure.scale_lattice().","message":"The CHGNetCalculator expects atom positions in Angstroms, not Bohr. Ensure your structure uses Angstrom units.","severity":"gotcha","affected_versions":"all"},{"fix":"Consider using a fine-tuned model or a different potential for molecular systems.","message":"CHGNet is pretrained primarily for inorganic solids. Use with molecules or organic crystals may yield poor accuracy.","severity":"gotcha","affected_versions":"all"},{"fix":"Use CHGNet.load() to instantiate the model.","message":"The 'from chgnet.model import CHGNet' method is deprecated in favor of 'CHGNet.load()'.","severity":"deprecated","affected_versions":"0.4.x"}],"env_vars":null,"search_vec":"'0.4.2':23 '3.10':26 'atomist':20,45 'cedergrouphub':40 'charg':4,18,35,47 'charge-inform':3,17,46 'chgnet':1,2 'energi':31 'forc':32 'graph':6 'inform':5,19,48 'materi':53 'materials-sci':52 'model':21,29 'network':8,14,43 'neural':7,13,42 'neural-network-potenti':41 'potenti':15,44,51 'predict':36 'pretrain':11 'provid':28 'python':25 'releas':37 'scienc':54 'stress':33 'support':24 'univers':12,50 'universal-potenti':49 'version':22","created_at":"2026-06-07T12:50:43.145599+00:00","updated_at":"2026-06-07T12:50:43.145599+00:00","problems":[{"fix":"Use: from chgnet.model import CHGNetCalculator","cause":"Incorrect import path; CHGNetCalculator is in chgnet.model.","error":"ImportError: cannot import name 'CHGNetCalculator' from 'chgnet'"},{"fix":"Use chgnet = CHGNet.load() instead of chgnet = CHGNet()","cause":"Trying to instantiate CHGNet directly without loading pretrained weights.","error":"RuntimeError: Model not loaded. Use CHGNet.load() first."},{"fix":"Assign calculator: structure.calc = CHGNetCalculator(chgnet)","cause":"CHGNetCalculator not attached to the structure.","error":"AttributeError: 'Structure' object has no attribute 'get_potential_energy'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/CederGroupHub/chgnet","github":"https://github.com/CederGroupHub/chgnet","docs":null,"changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","analytics"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}