Skip to content

Import Materials from Files

1. Introduction

Import materials from structure files in the formats supported by ASE (CIF, POSCAR and others). Some formats, such as espresso-in and espresso-out, are recognized from the file content.

2. Open the notebook

In JupyterLite, the notebook is made/import_materials_from_files.ipynb, entry 6.1.2 "Import from files in ASE-supported formats" of made/Introduction.ipynb.

3. Set the parameters

Cell 1 holds the parameters:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Upload files to this folder
FOLDER_PATH = "./uploads"

# By default, format will be guessed from file extension
# If set to specific format, or array of formats, notebook will only read that format
ENFORCED_FORMATS = None  # e.g. "cif" or ["cif", "espresso-in"]

# If set to true, the file extension will be included in the resulting material name
USE_FILE_NAME_NO_EXTENSION = False

# If set to true, the supported formats and required extensions will be printed below
SHOW_SUPPORTED_FORMATS = False

FOLDER_PATH is the folder the notebook reads every file from. The files are uploaded to it by opening the uploads folder in the JupyterLite file browser and dragging the files onto the sidebar. ENFORCED_FORMATS reads the files in one format, or tries the formats of a list in turn; with None, ASE infers the format of each file.

4. Run and read the result

Run the notebook with Run > Run All. The notebook prints the files it read and the files it could not read. When a file is unreadable, or with SHOW_SUPPORTED_FORMATS = True, it prints the table of the formats and file extensions ASE supports; the other files are converted. The materials are shown in 3D and passed back with set_materials, as in Structure Notebooks.

5. Interactive JupyterLite notebook

The interactive JupyterLite notebook for importing materials from files can be accessed below.