Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As mentioned in the cancelled #93 we need to complete the ways we provide to change a lattice, or to build one lattice from another. At the moment we cannot change the Bravais matrix, the type, the embedding dimension or the sublattice names of a lattice after creation. This PR, that builds on #94, does just that. It provides a method
lattice(lat; kw...)
wherekw
are any of the kwargs for lattice creation (bravais
,dim
,type
andnames
). To do this elegantly we needed to movebravais
to a kwarg, which was done in #94.From the implementation point of view, the key of this PR is to keep the mutation as efficient as possible. If we're only changing Bravais vectors, there is no need to touch the site position array or sublattice offsets. In contrast, if we're changing the dimension or the position type we need to allocate a whole new
Unitcell
. This done via parametric dispatch.An open question here is whether we want also a
hamiltonian(ham; kw...)
or not. The keywords ofhamiltonian
areorbitals
andtype
. Changing any of the two (unless only change the orbital names, but not their number, which is kind of a trivial change) implies recomputing the Hamiltonian (i.e. reapplying the model to the lattice, which often does not make sense without changing the model itself), so I'm inclined not to add such a method.