Skip to content

Commit

Permalink
update: add make slab if not
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Nov 25, 2024
1 parent c2021eb commit bfff098
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/py/mat3ra/made/tools/build/slab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ def create_slab(configuration: SlabConfiguration, termination: Optional[Terminat
builder = SlabBuilder()
termination = termination or builder.get_terminations(configuration)[0]
return builder.get_material(configuration, selector_parameters=SlabSelectorParameters(termination=termination))


def create_slab_if_not(material: Material, default_slab_configuration: SlabConfiguration):
slab = material
if not slab.metadata or slab.metadata["build"]["configuration"]["type"] != SlabConfiguration.__name__:
print("The material is not a slab. Creating a new slab...")
slab = create_slab(default_slab_configuration)
return slab

0 comments on commit bfff098

Please sign in to comment.