Ejemplo n.º 1
0
    def to_constructor_args(self,
                            crystal=None,
                            qpts=None,
                            frequencies=None,
                            structure_factors=None,
                            weights=None,
                            temperature=None):
        if crystal is None:
            crystal = Crystal(*self.crystal.to_constructor_args())
        if qpts is None:
            qpts = self.qpts
        if frequencies is None:
            frequencies = self.frequencies
        if structure_factors is None:
            structure_factors = self.structure_factors
        if weights is None:
            weights = self.weights
        if temperature is None:
            temperature = self.temperature

        kwargs = {}
        # Allow setting weights=False to not include weights in kwargs, to test
        # object creation when weights is not supplied
        if weights is not False:
            kwargs['weights'] = weights
        if temperature is not None:
            kwargs['temperature'] = temperature

        return (crystal, qpts, frequencies, structure_factors), kwargs
Ejemplo n.º 2
0
    def to_constructor_args(self,
                            crystal=None,
                            force_constants=None,
                            sc_matrix=None,
                            cell_origins=None,
                            born=None,
                            dielectric=None):
        if crystal is None:
            crystal = Crystal(*self.crystal.to_constructor_args())
        if force_constants is None:
            force_constants = self.force_constants
        if sc_matrix is None:
            sc_matrix = self.sc_matrix
        if cell_origins is None:
            cell_origins = self.cell_origins
        if born is None:
            born = self.born
        if dielectric is None:
            dielectric = self.dielectric

        kwargs = {}
        if born is not None:
            kwargs['born'] = born
        if dielectric is not None:
            kwargs['dielectric'] = dielectric

        return (crystal, force_constants, sc_matrix, cell_origins), kwargs
Ejemplo n.º 3
0
    def to_constructor_args(self, crystal=None, debye_waller=None,
                            temperature=None):
        if crystal is None:
            crystal = Crystal(*self.crystal.to_constructor_args())
        if debye_waller is None:
            debye_waller = self.debye_waller
        if temperature is None:
            temperature = self.temperature

        return crystal, debye_waller, temperature
Ejemplo n.º 4
0
    def to_constructor_args(self,
                            crystal=None,
                            qpts=None,
                            frequencies=None,
                            weights=None):
        if crystal is None:
            crystal = Crystal(*self.crystal.to_constructor_args())
        if qpts is None:
            qpts = self.qpts
        if frequencies is None:
            frequencies = self.frequencies
        if weights is None:
            weights = self.weights

        kwargs = {}
        # Allow setting weights=False to not include weights in kwargs, to test
        # object creation when weights is not supplied
        if weights is not False:
            kwargs['weights'] = weights

        return (crystal, qpts, frequencies), kwargs
Ejemplo n.º 5
0
 def nontrivial_crystal(self, request):
     """Some arbitrary non-diagonal lattices"""
     return Crystal(np.asarray(request.param, dtype=float
                               ) * ureg('angstrom'),
                    np.array([[0., 0., 0.]]),
                    np.array(['Si']), np.array([28.055]) * ureg('amu'))
Ejemplo n.º 6
0
 def trivial_crystal(self):
     return Crystal((np.array([[1., 0., 0.], [0., 2, 0.], [0., 0., 3]])
                     * ureg('angstrom')),
                    np.array([[0., 0., 0.]]),
                    np.array(['Si']), np.array([28.055]) * ureg('amu'))
Ejemplo n.º 7
0
 def test_faulty_creation(self, inject_faulty_elements):
     faulty_args, expected_exception = inject_faulty_elements
     with pytest.raises(expected_exception):
         Crystal(*faulty_args)
Ejemplo n.º 8
0
 def create_from_constructor(self, request):
     expected_crystal = request.param
     crystal = Crystal(*expected_crystal.to_constructor_args())
     return crystal, expected_crystal