def evaluate(self, symbols_and_values_in, symbol_out): tensor = ElasticTensor.from_voigt(symbols_and_values_in.get('E_ij')) if symbol_out == 'E': return tensor.y_mod return None
def _evaluate(self, symbol_values): structure = symbol_values['structure'] cij = symbol_values['C_ij'] elastic_tensor = ElasticTensor.from_voigt(cij) debye_temp = elastic_tensor.debye_temperature(structure) return {'d': debye_temp}
def elastic_constant(self, structure, potential, supercell=(1, 1, 1), nd=0.01, ns=0.05, num_norm=4, num_shear=4, etol=1e-6, ftol=1e-6, nsearch=2000, neval=10000): norm_strains = np.linspace(-nd, nd, num_norm).tolist() shear_strains = np.linspace(-ns, ns, num_shear).tolist() conventional_structure = self.conventional_structure(structure) deformation_set = DeformedStructureSet(conventional_structure * supercell, norm_strains=norm_strains, shear_strains=shear_strains) strains = [] stresses = [] if self.calculator_type == 'lammps': relax_lammps_script = load_lammps_set('relax') relax_lammps_script['fix'] = [] relax_lammps_script['minimize'] = '%f %f %d %d' % (etol, ftol, nsearch, neval) kwargs = {'lammps_set': relax_lammps_script} elif self.calculator_type == 'lammps_cython': kwargs = { 'lammps_additional_commands': [ 'min_style cg', 'minimize %f %f %d %d' % (etol, ftol, nsearch, neval) ] } async def calculate(): futures = [] for deformation, deformed_structure in zip( deformation_set.deformations, deformation_set): strains.append(Strain.from_deformation(deformation)) futures.append(await self.calculator.submit(deformed_structure, potential, properties={'stress'}, **kwargs)) for result in await asyncio.gather(*futures): stress = Stress(np.array(result['results']['stress']) * 1e-4) # Convert to GPa stresses.append(stress) self._run_async_func(calculate()) return ElasticTensor.from_independent_strains(strains, stresses, Stress(np.zeros((3, 3))))
def get_debye_temp(mpid): """ Calculates the debye temperature from eleastic tensors on the Materials Project Credits: Joseph Montoya """ pd.np.seterr(over="ignore") # ignore overflow in double scalars data = mpr.get_data(mpid)[0] struct = Structure.from_str(data['cif'], fmt='cif') c_ij = ElasticTensor.from_voigt(data['elasticity']['elastic_tensor']) td = c_ij.debye_temperature(struct) return td
def evaluate(self, symbols_and_values_in, symbol_out): if symbol_out == 'Cij': tensor = ComplianceTensor.from_voigt(symbols_and_values_in.get('Sij')) return tensor.elastic_tensor.voigt elif symbol_out == 'Sij': tensor = ElasticTensor.from_voigt(symbols_and_values_in.get('Cij')) return tensor.compliance_tensor.voigt return None
def elastic_constant(self, structure, potential, supercell=(1, 1, 1), nd=0.01, ns=0.05, num_norm=4, num_shear=4, etol=1e-6, ftol=1e-6, nsearch=2000, neval=10000): norm_strains = np.linspace(-nd, nd, num_norm).tolist() shear_strains = np.linspace(-ns, ns, num_shear).tolist() conventional_structure = self.conventional_structure(structure) deformation_set = DeformedStructureSet(conventional_structure * supercell, norm_strains=norm_strains, shear_strains=shear_strains) strains = [] stresses = [] if self.calculator_type == 'lammps': relax_lammps_script = load_lammps_set('relax') relax_lammps_script['fix'] = [] relax_lammps_script['minimize'] = '%f %f %d %d' % (etol, ftol, nsearch, neval) kwargs = {'lammps_set': relax_lammps_script} elif self.calculator_type == 'lammps_cython': kwargs = {'lammps_additional_commands': [ 'min_style cg', 'minimize %f %f %d %d' % (etol, ftol, nsearch, neval) ]} async def calculate(): futures = [] for deformation, deformed_structure in zip(deformation_set.deformations, deformation_set): strains.append(Strain.from_deformation(deformation)) futures.append(await self.calculator.submit( deformed_structure, potential, properties={'stress'}, **kwargs)) for result in await asyncio.gather(*futures): stress = Stress(np.array(result['results']['stress']) * 1e-4) # Convert to GPa stresses.append(stress) self._run_async_func(calculate()) return ElasticTensor.from_independent_strains(strains, stresses, Stress(np.zeros((3, 3))))
subprocess.call(['lammps', '-i', 'lammps.in'], cwd=deformation_directory, stdout=subprocess.PIPE) lammps_log = LammpsLog(os.path.join(deformation_directory, 'lammps.log')) stress = Stress(lammps_log.get_stress(-1)) strained_structures.append({ 'strain': strain, 'structrure': strained_structure, 'stress': stress / -10000.0 # bar to GPa }) strains = [defo['strain'] for defo in strained_structures] stresses = [defo['stress'] for defo in strained_structures] elastic = ElasticTensor.from_pseudoinverse(strains, stresses) print('Stiffness Tensor') for row in elastic.voigt: print( '{:+8.1f} {:+8.1f} {:+8.1f} {:+8.1f} {:+8.1f} {:+8.1f}\n'.format(*row)) print('Shear Modulus G_V', elastic.g_voigt) print('Shear Modulus G_R', elastic.g_reuss) print('Shear Modulus G_vrh', elastic.g_vrh) print('Bulk Modulus K_V', elastic.k_voigt) print('Bulk Modulus K_R', elastic.k_reuss) print('Bulk Modulus K_vrh', elastic.k_vrh) print('Elastic Anisotropy', elastic.universal_anisotropy)