Open anderscmathisen opened 1 year ago
Yes, having a correct structure (with a lattice) is a responsibility of the user. The documentation states that if a structure
is not passed to Phase
, a default is used. The default is a default diffpy.structure.lattice.Lattice
with (a, b, c, alpha, beta, gamma) = (1, 1, 1, 90, 90, 90), regardless of symmetry. Changing this is on my orix todo list, but I don't have time at the moment.
The solution I see is that when a lattice is not given, we set it to (1, 1, 1, 90, 90, 90) unless the symmetry given belongs to the hexagonal or trigonal crystal system, in which case we use (1, 1, 1, 90, 90, 120).
The solution I see is that when a lattice is not given, we set it to (1, 1, 1, 90, 90, 90) unless the symmetry given belongs to the hexagonal or trigonal crystal system, in which case we use (1, 1, 1, 90, 90, 120).
This is a good solution, but I think a warning printed to the user might still be beneficial as for instance for the hexagonal systems, calculations such as angles are dependent on the a/c ratio.
I think in this case another option could be to have no default structure and require the user to define it, if it is easily forgotten and leads to incorrect results.
What might help is if the docstring for Phase includes some basic examples, eg. cubic and hexagonal phase setups, and also if it explicitly specifies that the default structure is cubic without referring the user to diffpy. What do you think to this?
I think a warning printed to the user might still be beneficial as for instance for the hexagonal systems, calculations such as angles are dependent on the a/c ratio.
I agree that it is useful for a user to be warned when they create a Miller
instance with an hexagonal/trigonal Phase
with an invalid lattice. In this case a user is specifically looking to analyze crystal directions or plane normals. I think a warning in this case might be suitable in every situation, actually... What I'd like to avoid is a warning being raised when the user does not care about the a/c ratio.
What might help is if the docstring for Phase includes some basic examples, eg. cubic and hexagonal phase setups, and also if it explicitly specifies that the default structure is cubic without referring the user to diffpy. What do you think to this?
Yes, initialization of a Phase
instance should be made simpler. What I'd like to add is class methods to create a base Phase
for each crystal system allowing the necessary lattice parameters (and corresponding symmetry, allowing to set this and a structure if desirable). These could then be used in the docstring.
specifies that the default structure is cubic without referring the user to diffpy
Yes, we should specify that the default is (1, 1, 1, 90, 90, 90) unless trigonal/hexagonal.
A few times now I have been puzzled by Miller giving "wrong" angles between vectors. The issue every time is that I forget to add a
Structure
argument to thePhase
.Should we add a warning when creating
Miller
objects (or perhaps thePhase
object) that if aPhase
with noStructure
is passed, then calculations might not be correct? (at least for non cubic systems)