idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
33,500 | def run ( self , verbose = False ) : if verbose : print ( ( "#%11s" + "%14s" * 4 ) % ( "T" , "E_0" , "B_0" , "B'_0" , "V_0" ) ) num_elems = self . _get_num_elems ( self . _all_temperatures ) + 1 if num_elems > len ( self . _all_temperatures ) : num_elems -= 1 temperatures = [ ] parameters = [ ] free_energies = [ ] for ... | Fit parameters to EOS at temperatures |
33,501 | def _trim_cell ( relative_axes , cell , symprec ) : positions = cell . get_scaled_positions ( ) numbers = cell . get_atomic_numbers ( ) masses = cell . get_masses ( ) magmoms = cell . get_magnetic_moments ( ) lattice = cell . get_cell ( ) trimmed_lattice = np . dot ( relative_axes . T , lattice ) trimmed_positions = [ ... | Trim overlapping atoms |
33,502 | def get_reduced_bases ( lattice , method = 'delaunay' , tolerance = 1e-5 ) : if method == 'niggli' : return spg . niggli_reduce ( lattice , eps = tolerance ) else : return spg . delaunay_reduce ( lattice , eps = tolerance ) | Search kinds of shortest basis vectors |
33,503 | def get_smallest_vectors ( supercell_bases , supercell_pos , primitive_pos , symprec = 1e-5 ) : reduced_bases = get_reduced_bases ( supercell_bases , method = 'delaunay' , tolerance = symprec ) trans_mat_float = np . dot ( supercell_bases , np . linalg . inv ( reduced_bases ) ) trans_mat = np . rint ( trans_mat_float )... | Find shortest atomic pair vectors |
33,504 | def compute_all_sg_permutations ( positions , rotations , translations , lattice , symprec ) : out = [ ] for ( sym , t ) in zip ( rotations , translations ) : rotated_positions = np . dot ( positions , sym . T ) + t out . append ( compute_permutation_for_rotation ( positions , rotated_positions , lattice , symprec ) ) ... | Compute a permutation for every space group operation . |
33,505 | def compute_permutation_for_rotation ( positions_a , positions_b , lattice , symprec ) : def sort_by_lattice_distance ( fracs ) : carts = np . dot ( fracs - np . rint ( fracs ) , lattice . T ) perm = np . argsort ( np . sum ( carts ** 2 , axis = 1 ) ) sorted_fracs = np . array ( fracs [ perm ] , dtype = 'double' , orde... | Get the overall permutation such that |
33,506 | def _compute_permutation_c ( positions_a , positions_b , lattice , symprec ) : permutation = np . zeros ( shape = ( len ( positions_a ) , ) , dtype = 'intc' ) def permutation_error ( ) : raise ValueError ( "Input forces are not enough to calculate force constants, " "or something wrong (e.g. crystal structure does not ... | Version of _compute_permutation_for_rotation which just directly calls the C function without any conditioning of the data . Skipping the conditioning step makes this EXTREMELY slow on large structures . |
33,507 | def estimate_supercell_matrix ( spglib_dataset , max_num_atoms = 120 ) : spg_num = spglib_dataset [ 'number' ] num_atoms = len ( spglib_dataset [ 'std_types' ] ) lengths = _get_lattice_parameters ( spglib_dataset [ 'std_lattice' ] ) if spg_num <= 74 : multi = _get_multiplicity_abc ( num_atoms , lengths , max_num_atoms ... | Estimate supercell matrix from conventional cell |
33,508 | def _get_lattice_parameters ( lattice ) : return np . array ( np . sqrt ( np . dot ( lattice . T , lattice ) . diagonal ( ) ) , dtype = 'double' ) | Return basis vector lengths |
33,509 | def _second ( self ) : self . _second_one_loop ( ) A = self . _A if A [ 2 , 1 ] == 0 : return True elif A [ 2 , 1 ] % A [ 1 , 1 ] == 0 : self . _second_finalize ( ) self . _Ps += self . _L self . _L = [ ] return True else : return False | Find Smith normal form for Right - low 2x2 matrix |
33,510 | def _second_column ( self ) : if self . _A [ 1 , 1 ] == 0 and self . _A [ 2 , 1 ] != 0 : self . _swap_rows ( 1 , 2 ) if self . _A [ 2 , 1 ] != 0 : self . _zero_second_column ( ) | Right - low 2x2 matrix |
33,511 | def _swap_rows ( self , i , j ) : L = np . eye ( 3 , dtype = 'intc' ) L [ i , i ] = 0 L [ j , j ] = 0 L [ i , j ] = 1 L [ j , i ] = 1 self . _L . append ( L . copy ( ) ) self . _A = np . dot ( L , self . _A ) | Swap i and j rows |
33,512 | def _flip_sign_row ( self , i ) : L = np . eye ( 3 , dtype = 'intc' ) L [ i , i ] = - 1 self . _L . append ( L . copy ( ) ) self . _A = np . dot ( L , self . _A ) | Multiply - 1 for all elements in row |
33,513 | def dataset ( self , dataset ) : if 'displacements' in dataset : natom = self . _supercell . get_number_of_atoms ( ) if type ( dataset [ 'displacements' ] ) is np . ndarray : if dataset [ 'displacements' ] . ndim in ( 1 , 2 ) : d = dataset [ 'displacements' ] . reshape ( ( - 1 , natom , 3 ) ) dataset [ 'displacements' ... | Set dataset having displacements and optionally forces |
33,514 | def forces ( self , sets_of_forces ) : if 'first_atoms' in self . _displacement_dataset : for disp , forces in zip ( self . _displacement_dataset [ 'first_atoms' ] , sets_of_forces ) : disp [ 'forces' ] = forces elif 'forces' in self . _displacement_dataset : forces = np . array ( sets_of_forces , dtype = 'double' , or... | Set forces in displacement dataset . |
33,515 | def force_constants ( self , force_constants ) : if type ( force_constants ) is np . ndarray : fc_shape = force_constants . shape if fc_shape [ 0 ] != fc_shape [ 1 ] : if self . _primitive . get_number_of_atoms ( ) != fc_shape [ 0 ] : msg = ( "Force constants shape disagrees with crystal " "structure setting. This may ... | Set force constants |
33,516 | def generate_displacements ( self , distance = 0.01 , is_plusminus = 'auto' , is_diagonal = True , is_trigonal = False ) : displacement_directions = get_least_displacements ( self . _symmetry , is_plusminus = is_plusminus , is_diagonal = is_diagonal , is_trigonal = is_trigonal , log_level = self . _log_level ) displace... | Generate displacement dataset |
33,517 | def get_dynamical_matrix_at_q ( self , q ) : self . _set_dynamical_matrix ( ) if self . _dynamical_matrix is None : msg = ( "Dynamical matrix has not yet built." ) raise RuntimeError ( msg ) self . _dynamical_matrix . set_dynamical_matrix ( q ) return self . _dynamical_matrix . get_dynamical_matrix ( ) | Calculate dynamical matrix at a given q - point |
33,518 | def get_frequencies ( self , q ) : self . _set_dynamical_matrix ( ) if self . _dynamical_matrix is None : msg = ( "Dynamical matrix has not yet built." ) raise RuntimeError ( msg ) self . _dynamical_matrix . set_dynamical_matrix ( q ) dm = self . _dynamical_matrix . get_dynamical_matrix ( ) frequencies = [ ] for eig in... | Calculate phonon frequencies at a given q - point |
33,519 | def get_frequencies_with_eigenvectors ( self , q ) : self . _set_dynamical_matrix ( ) if self . _dynamical_matrix is None : msg = ( "Dynamical matrix has not yet built." ) raise RuntimeError ( msg ) self . _dynamical_matrix . set_dynamical_matrix ( q ) dm = self . _dynamical_matrix . get_dynamical_matrix ( ) frequencie... | Calculate phonon frequencies and eigenvectors at a given q - point |
33,520 | def run_band_structure ( self , paths , with_eigenvectors = False , with_group_velocities = False , is_band_connection = False , path_connections = None , labels = None , is_legacy_plot = False ) : if self . _dynamical_matrix is None : msg = ( "Dynamical matrix has not yet built." ) raise RuntimeError ( msg ) if with_g... | Run phonon band structure calculation . |
33,521 | def init_mesh ( self , mesh = 100.0 , shift = None , is_time_reversal = True , is_mesh_symmetry = True , with_eigenvectors = False , with_group_velocities = False , is_gamma_center = False , use_iter_mesh = False ) : if self . _dynamical_matrix is None : msg = "Dynamical matrix has not yet built." raise RuntimeError ( ... | Initialize mesh sampling phonon calculation without starting to run . |
33,522 | def run_mesh ( self , mesh = 100.0 , shift = None , is_time_reversal = True , is_mesh_symmetry = True , with_eigenvectors = False , with_group_velocities = False , is_gamma_center = False ) : self . init_mesh ( mesh = mesh , shift = shift , is_time_reversal = is_time_reversal , is_mesh_symmetry = is_mesh_symmetry , wit... | Run mesh sampling phonon calculation . |
33,523 | def set_mesh ( self , mesh , shift = None , is_time_reversal = True , is_mesh_symmetry = True , is_eigenvectors = False , is_gamma_center = False , run_immediately = True ) : warnings . warn ( "Phonopy.set_mesh is deprecated. " "Use Phonopy.run_mesh." , DeprecationWarning ) if self . _group_velocity is None : with_grou... | Phonon calculations on sampling mesh grids |
33,524 | def get_mesh_dict ( self ) : if self . _mesh is None : msg = ( "run_mesh has to be done." ) raise RuntimeError ( msg ) retdict = { 'qpoints' : self . _mesh . qpoints , 'weights' : self . _mesh . weights , 'frequencies' : self . _mesh . frequencies , 'eigenvectors' : self . _mesh . eigenvectors , 'group_velocities' : se... | Returns calculated mesh sampling phonons |
33,525 | def set_iter_mesh ( self , mesh , shift = None , is_time_reversal = True , is_mesh_symmetry = True , is_eigenvectors = False , is_gamma_center = False ) : warnings . warn ( "Phonopy.set_iter_mesh is deprecated. " "Use Phonopy.run_mesh with use_iter_mesh=True." , DeprecationWarning ) self . run_mesh ( mesh = mesh , shif... | Create an IterMesh instancer |
33,526 | def run_qpoints ( self , q_points , with_eigenvectors = False , with_group_velocities = False , with_dynamical_matrices = False , nac_q_direction = None ) : if self . _dynamical_matrix is None : msg = ( "Dynamical matrix has not yet built." ) raise RuntimeError ( msg ) if with_group_velocities : if self . _group_veloci... | Phonon calculations on q - points . |
33,527 | def run_total_dos ( self , sigma = None , freq_min = None , freq_max = None , freq_pitch = None , use_tetrahedron_method = True ) : if self . _mesh is None : msg = "run_mesh has to be done before DOS calculation." raise RuntimeError ( msg ) total_dos = TotalDos ( self . _mesh , sigma = sigma , use_tetrahedron_method = ... | Calculate total DOS from phonons on sampling mesh . |
33,528 | def get_total_DOS ( self ) : warnings . warn ( "Phonopy.get_total_DOS is deprecated. " "Use Phonopy.get_total_dos_dict." , DeprecationWarning ) dos = self . get_total_dos_dict ( ) return dos [ 'frequency_points' ] , dos [ 'total_dos' ] | Return frequency points and total DOS as a tuple . |
33,529 | def run_projected_dos ( self , sigma = None , freq_min = None , freq_max = None , freq_pitch = None , use_tetrahedron_method = True , direction = None , xyz_projection = False ) : self . _pdos = None if self . _mesh is None : msg = "run_mesh has to be done before PDOS calculation." raise RuntimeError ( msg ) if not sel... | Calculate projected DOS from phonons on sampling mesh . |
33,530 | def get_partial_DOS ( self ) : warnings . warn ( "Phonopy.get_partial_DOS is deprecated. " "Use Phonopy.get_projected_dos_dict." , DeprecationWarning ) pdos = self . get_projected_dos_dict ( ) return pdos [ 'frequency_points' ] , pdos [ 'projected_dos' ] | Return frequency points and partial DOS as a tuple . |
33,531 | def plot_projected_dos ( self , pdos_indices = None , legend = None ) : import matplotlib . pyplot as plt fig , ax = plt . subplots ( ) ax . xaxis . set_ticks_position ( 'both' ) ax . yaxis . set_ticks_position ( 'both' ) ax . xaxis . set_tick_params ( which = 'both' , direction = 'in' ) ax . yaxis . set_tick_params ( ... | Plot projected DOS |
33,532 | def run_thermal_properties ( self , t_min = 0 , t_max = 1000 , t_step = 10 , temperatures = None , is_projection = False , band_indices = None , cutoff_frequency = None , pretend_real = False ) : if self . _mesh is None : msg = ( "run_mesh has to be done before" "run_thermal_properties." ) raise RuntimeError ( msg ) tp... | Calculate thermal properties at constant volume |
33,533 | def get_thermal_properties ( self ) : warnings . warn ( "Phonopy.get_thermal_properties is deprecated. " "Use Phonopy.get_thermal_properties_dict." , DeprecationWarning ) tp = self . get_thermal_properties_dict ( ) return ( tp [ 'temperatures' ] , tp [ 'free_energy' ] , tp [ 'entropy' ] , tp [ 'heat_capacity' ] ) | Return thermal properties |
33,534 | def run_thermal_displacements ( self , t_min = 0 , t_max = 1000 , t_step = 10 , temperatures = None , direction = None , freq_min = None , freq_max = None ) : if self . _dynamical_matrix is None : msg = ( "Dynamical matrix has not yet built." ) raise RuntimeError ( msg ) if self . _mesh is None : msg = ( "run_mesh has ... | Prepare thermal displacements calculation |
33,535 | def run_thermal_displacement_matrices ( self , t_min = 0 , t_max = 1000 , t_step = 10 , temperatures = None , freq_min = None , freq_max = None ) : if self . _dynamical_matrix is None : msg = ( "Dynamical matrix has not yet built." ) raise RuntimeError ( msg ) if self . _mesh is None : msg = ( "run_mesh has to be done.... | Prepare thermal displacement matrices |
33,536 | def set_modulations ( self , dimension , phonon_modes , delta_q = None , derivative_order = None , nac_q_direction = None ) : if self . _dynamical_matrix is None : msg = ( "Dynamical matrix has not yet built." ) raise RuntimeError ( msg ) self . _modulation = Modulation ( self . _dynamical_matrix , dimension , phonon_m... | Generate atomic displacements of phonon modes . |
33,537 | def set_irreps ( self , q , is_little_cogroup = False , nac_q_direction = None , degeneracy_tolerance = 1e-4 ) : if self . _dynamical_matrix is None : msg = ( "Dynamical matrix has not yet built." ) raise RuntimeError ( msg ) self . _irreps = IrReps ( self . _dynamical_matrix , q , is_little_cogroup = is_little_cogroup... | Identify ir - reps of phonon modes . |
33,538 | def init_dynamic_structure_factor ( self , Qpoints , T , atomic_form_factor_func = None , scattering_lengths = None , freq_min = None , freq_max = None ) : if self . _mesh is None : msg = ( "run_mesh has to be done before initializing dynamic" "structure factor." ) raise RuntimeError ( msg ) if not self . _mesh . with_... | Initialize dynamic structure factor calculation . |
33,539 | def run_dynamic_structure_factor ( self , Qpoints , T , atomic_form_factor_func = None , scattering_lengths = None , freq_min = None , freq_max = None ) : self . init_dynamic_structure_factor ( Qpoints , T , atomic_form_factor_func = atomic_form_factor_func , scattering_lengths = scattering_lengths , freq_min = freq_mi... | Run dynamic structure factor calculation |
33,540 | def save ( self , filename = "phonopy_params.yaml" , settings = None ) : phpy_yaml = PhonopyYaml ( calculator = self . _calculator , settings = settings ) phpy_yaml . set_phonon_info ( self ) with open ( filename , 'w' ) as w : w . write ( str ( phpy_yaml ) ) | Save parameters in Phonopy instants into file . |
33,541 | def length2mesh ( length , lattice , rotations = None ) : rec_lattice = np . linalg . inv ( lattice ) rec_lat_lengths = np . sqrt ( np . diagonal ( np . dot ( rec_lattice . T , rec_lattice ) ) ) mesh_numbers = np . rint ( rec_lat_lengths * length ) . astype ( int ) if rotations is not None : reclat_equiv = get_lattice_... | Convert length to mesh for q - point sampling |
33,542 | def _get_population ( self , freq , t ) : condition = t > 1.0 if type ( condition ) == bool or type ( condition ) == np . bool_ : if condition : return 1.0 / ( np . exp ( freq * THzToEv / ( Kb * t ) ) - 1 ) else : return 0.0 else : vals = np . zeros ( len ( t ) , dtype = 'double' ) vals [ condition ] = 1.0 / ( np . exp... | Return phonon population number |
33,543 | def _project_eigenvectors ( self ) : self . _p_eigenvectors = [ ] for vecs_q in self . _eigenvectors : p_vecs_q = [ ] for vecs in vecs_q . T : p_vecs_q . append ( np . dot ( vecs . reshape ( - 1 , 3 ) , self . _projection_direction ) ) self . _p_eigenvectors . append ( np . transpose ( p_vecs_q ) ) self . _p_eigenvecto... | Eigenvectors are projected along Cartesian direction |
33,544 | def get_symmetry ( cell , symprec = 1e-5 , angle_tolerance = - 1.0 ) : _set_no_error ( ) lattice , positions , numbers , magmoms = _expand_cell ( cell ) if lattice is None : return None multi = 48 * len ( positions ) rotation = np . zeros ( ( multi , 3 , 3 ) , dtype = 'intc' ) translation = np . zeros ( ( multi , 3 ) ,... | This gives crystal symmetry operations from a crystal structure . |
33,545 | def get_symmetry_dataset ( cell , symprec = 1e-5 , angle_tolerance = - 1.0 , hall_number = 0 ) : _set_no_error ( ) lattice , positions , numbers , _ = _expand_cell ( cell ) if lattice is None : return None spg_ds = spg . dataset ( lattice , positions , numbers , hall_number , symprec , angle_tolerance ) if spg_ds is No... | Search symmetry dataset from an input cell . |
33,546 | def get_spacegroup ( cell , symprec = 1e-5 , angle_tolerance = - 1.0 , symbol_type = 0 ) : _set_no_error ( ) dataset = get_symmetry_dataset ( cell , symprec = symprec , angle_tolerance = angle_tolerance ) if dataset is None : return None spg_type = get_spacegroup_type ( dataset [ 'hall_number' ] ) if symbol_type == 1 :... | Return space group in international table symbol and number as a string . |
33,547 | def get_hall_number_from_symmetry ( rotations , translations , symprec = 1e-5 ) : r = np . array ( rotations , dtype = 'intc' , order = 'C' ) t = np . array ( translations , dtype = 'double' , order = 'C' ) hall_number = spg . hall_number_from_symmetry ( r , t , symprec ) return hall_number | Hall number is obtained from a set of symmetry operations . |
33,548 | def get_spacegroup_type ( hall_number ) : _set_no_error ( ) keys = ( 'number' , 'international_short' , 'international_full' , 'international' , 'schoenflies' , 'hall_symbol' , 'choice' , 'pointgroup_schoenflies' , 'pointgroup_international' , 'arithmetic_crystal_class_number' , 'arithmetic_crystal_class_symbol' ) spg_... | Translate Hall number to space group type information . |
33,549 | def get_pointgroup ( rotations ) : _set_no_error ( ) pointgroup = spg . pointgroup ( np . array ( rotations , dtype = 'intc' , order = 'C' ) ) _set_error_message ( ) return pointgroup | Return point group in international table symbol and number . |
33,550 | def standardize_cell ( cell , to_primitive = False , no_idealize = False , symprec = 1e-5 , angle_tolerance = - 1.0 ) : _set_no_error ( ) lattice , _positions , _numbers , _ = _expand_cell ( cell ) if lattice is None : return None num_atom = len ( _positions ) positions = np . zeros ( ( num_atom * 4 , 3 ) , dtype = 'do... | Return standardized cell . |
33,551 | def find_primitive ( cell , symprec = 1e-5 , angle_tolerance = - 1.0 ) : _set_no_error ( ) lattice , positions , numbers , _ = _expand_cell ( cell ) if lattice is None : return None num_atom_prim = spg . primitive ( lattice , positions , numbers , symprec , angle_tolerance ) _set_error_message ( ) if num_atom_prim > 0 ... | Primitive cell is searched in the input cell . |
33,552 | def get_symmetry_from_database ( hall_number ) : _set_no_error ( ) rotations = np . zeros ( ( 192 , 3 , 3 ) , dtype = 'intc' ) translations = np . zeros ( ( 192 , 3 ) , dtype = 'double' ) num_sym = spg . symmetry_from_database ( rotations , translations , hall_number ) _set_error_message ( ) if num_sym is None : return... | Return symmetry operations corresponding to a Hall symbol . |
33,553 | def get_grid_point_from_address ( grid_address , mesh ) : _set_no_error ( ) return spg . grid_point_from_address ( np . array ( grid_address , dtype = 'intc' ) , np . array ( mesh , dtype = 'intc' ) ) | Return grid point index by tranlating grid address |
33,554 | def get_ir_reciprocal_mesh ( mesh , cell , is_shift = None , is_time_reversal = True , symprec = 1e-5 , is_dense = False ) : _set_no_error ( ) lattice , positions , numbers , _ = _expand_cell ( cell ) if lattice is None : return None if is_dense : dtype = 'uintp' else : dtype = 'intc' grid_mapping_table = np . zeros ( ... | Return k - points mesh and k - point map to the irreducible k - points . |
33,555 | def get_stabilized_reciprocal_mesh ( mesh , rotations , is_shift = None , is_time_reversal = True , qpoints = None , is_dense = False ) : _set_no_error ( ) if is_dense : dtype = 'uintp' else : dtype = 'intc' mapping_table = np . zeros ( np . prod ( mesh ) , dtype = dtype ) grid_address = np . zeros ( ( np . prod ( mesh... | Return k - point map to the irreducible k - points and k - point grid points . |
33,556 | def relocate_BZ_grid_address ( grid_address , mesh , reciprocal_lattice , is_shift = None , is_dense = False ) : _set_no_error ( ) if is_shift is None : _is_shift = np . zeros ( 3 , dtype = 'intc' ) else : _is_shift = np . array ( is_shift , dtype = 'intc' ) bz_grid_address = np . zeros ( ( np . prod ( np . add ( mesh ... | Grid addresses are relocated to be inside first Brillouin zone . |
33,557 | def delaunay_reduce ( lattice , eps = 1e-5 ) : _set_no_error ( ) delaunay_lattice = np . array ( np . transpose ( lattice ) , dtype = 'double' , order = 'C' ) result = spg . delaunay_reduce ( delaunay_lattice , float ( eps ) ) _set_error_message ( ) if result == 0 : return None else : return np . array ( np . transpose... | Run Delaunay reduction |
33,558 | def niggli_reduce ( lattice , eps = 1e-5 ) : _set_no_error ( ) niggli_lattice = np . array ( np . transpose ( lattice ) , dtype = 'double' , order = 'C' ) result = spg . niggli_reduce ( niggli_lattice , float ( eps ) ) _set_error_message ( ) if result == 0 : return None else : return np . array ( np . transpose ( niggl... | Run Niggli reduction |
33,559 | def get_FORCE_SETS_lines ( dataset , forces = None ) : if 'first_atoms' in dataset : return _get_FORCE_SETS_lines_type1 ( dataset , forces = forces ) elif 'forces' in dataset : return _get_FORCE_SETS_lines_type2 ( dataset ) | Generate FORCE_SETS string |
33,560 | def write_FORCE_CONSTANTS ( force_constants , filename = 'FORCE_CONSTANTS' , p2s_map = None ) : lines = get_FORCE_CONSTANTS_lines ( force_constants , p2s_map = p2s_map ) with open ( filename , 'w' ) as w : w . write ( "\n" . join ( lines ) ) | Write force constants in text file format . |
33,561 | def write_force_constants_to_hdf5 ( force_constants , filename = 'force_constants.hdf5' , p2s_map = None , physical_unit = None , compression = None ) : try : import h5py except ImportError : raise ModuleNotFoundError ( "You need to install python-h5py." ) with h5py . File ( filename , 'w' ) as w : w . create_dataset (... | Write force constants in hdf5 format . |
33,562 | def get_band_qpoints ( band_paths , npoints = 51 , rec_lattice = None ) : npts = _get_npts ( band_paths , npoints , rec_lattice ) qpoints_of_paths = [ ] c = 0 for band_path in band_paths : nd = len ( band_path ) for i in range ( nd - 1 ) : delta = np . subtract ( band_path [ i + 1 ] , band_path [ i ] ) / ( npts [ c ] -... | Generate qpoints for band structure path |
33,563 | def get_band_qpoints_by_seekpath ( primitive , npoints , is_const_interval = False ) : try : import seekpath except ImportError : raise ImportError ( "You need to install seekpath." ) band_path = seekpath . get_path ( primitive . totuple ( ) ) point_coords = band_path [ 'point_coords' ] qpoints_of_paths = [ ] if is_con... | q - points along BZ high symmetry paths are generated using seekpath . |
33,564 | def get_commensurate_points ( supercell_matrix ) : smat = np . array ( supercell_matrix , dtype = int ) rec_primitive = PhonopyAtoms ( numbers = [ 1 ] , scaled_positions = [ [ 0 , 0 , 0 ] ] , cell = np . diag ( [ 1 , 1 , 1 ] ) , pbc = True ) rec_supercell = get_supercell ( rec_primitive , smat . T ) q_pos = rec_superce... | Commensurate q - points are returned . |
33,565 | def get_commensurate_points_in_integers ( supercell_matrix ) : smat = np . array ( supercell_matrix , dtype = int ) snf = SNF3x3 ( smat . T ) snf . run ( ) D = snf . A . diagonal ( ) b , c , a = np . meshgrid ( range ( D [ 1 ] ) , range ( D [ 2 ] ) , range ( D [ 0 ] ) ) lattice_points = np . dot ( np . c_ [ a . ravel (... | Commensurate q - points in integer representation are returned . |
33,566 | def write_vasp ( filename , cell , direct = True ) : lines = get_vasp_structure_lines ( cell , direct = direct ) with open ( filename , 'w' ) as w : w . write ( "\n" . join ( lines ) ) | Write crystal structure to a VASP POSCAR style file . |
33,567 | def _set_lattice ( self ) : unit = self . _values [ 0 ] if unit == 'alat' : if not self . _tags [ 'celldm(1)' ] : print ( "celldm(1) has to be specified when using alat." ) sys . exit ( 1 ) else : factor = self . _tags [ 'celldm(1)' ] elif unit == 'angstrom' : factor = 1.0 / Bohr else : factor = 1.0 if len ( self . _va... | Calculate and set lattice parameters . |
33,568 | def run ( self , cell , is_full_fc = False , parse_fc = True ) : with open ( self . _filename ) as f : fc_dct = self . _parse_q2r ( f ) self . dimension = fc_dct [ 'dimension' ] self . epsilon = fc_dct [ 'dielectric' ] self . borns = fc_dct [ 'born' ] if parse_fc : ( self . fc , self . primitive , self . supercell ) = ... | Make supercell force constants readable for phonopy |
33,569 | def _parse_q2r ( self , f ) : natom , dim , epsilon , borns = self . _parse_parameters ( f ) fc_dct = { 'fc' : self . _parse_fc ( f , natom , dim ) , 'dimension' : dim , 'dielectric' : epsilon , 'born' : borns } return fc_dct | Parse q2r output file |
33,570 | def _parse_fc ( self , f , natom , dim ) : ndim = np . prod ( dim ) fc = np . zeros ( ( natom , natom * ndim , 3 , 3 ) , dtype = 'double' , order = 'C' ) for k , l , i , j in np . ndindex ( ( 3 , 3 , natom , natom ) ) : line = f . readline ( ) for i_dim in range ( ndim ) : line = f . readline ( ) fc [ j , i * ndim + i_... | Parse force constants part |
33,571 | def get_cp2k_structure ( atoms ) : from cp2k_tools . generator import dict2cp2k cp2k_cell = { sym : ( '[angstrom]' , ) + tuple ( coords ) for sym , coords in zip ( ( 'a' , 'b' , 'c' ) , atoms . get_cell ( ) * Bohr ) } cp2k_cell [ 'periodic' ] = 'XYZ' cp2k_coord = { 'scaled' : True , '*' : [ [ sym ] + list ( coord ) for... | Convert the atoms structure to a CP2K input file skeleton string |
33,572 | def plot_qha ( self , thin_number = 10 , volume_temp_exp = None ) : return self . _qha . plot ( thin_number = thin_number , volume_temp_exp = volume_temp_exp ) | Returns matplotlib . pyplot of QHA fitting curves at temperatures |
33,573 | def get_fc2 ( supercell , symmetry , dataset , atom_list = None , decimals = None ) : if atom_list is None : fc_dim0 = supercell . get_number_of_atoms ( ) else : fc_dim0 = len ( atom_list ) force_constants = np . zeros ( ( fc_dim0 , supercell . get_number_of_atoms ( ) , 3 , 3 ) , dtype = 'double' , order = 'C' ) atom_l... | Force constants are computed . |
33,574 | def set_permutation_symmetry ( force_constants ) : fc_copy = force_constants . copy ( ) for i in range ( force_constants . shape [ 0 ] ) : for j in range ( force_constants . shape [ 1 ] ) : force_constants [ i , j ] = ( force_constants [ i , j ] + fc_copy [ j , i ] . T ) / 2 | Enforce permutation symmetry to force cosntants by |
33,575 | def similarity_transformation ( rot , mat ) : return np . dot ( rot , np . dot ( mat , np . linalg . inv ( rot ) ) ) | R x M x R^ - 1 |
33,576 | def _get_sym_mappings_from_permutations ( permutations , atom_list_done ) : assert permutations . ndim == 2 num_pos = permutations . shape [ 1 ] map_atoms = np . zeros ( ( num_pos , ) , dtype = 'intc' ) - 1 map_syms = np . zeros ( ( num_pos , ) , dtype = 'intc' ) - 1 atom_list_done = set ( atom_list_done ) for atom_tod... | This can be thought of as computing map_atom_disp and map_sym for all atoms except done using permutations instead of by computing overlaps . |
33,577 | def get_least_displacements ( symmetry , is_plusminus = 'auto' , is_diagonal = True , is_trigonal = False , log_level = 0 ) : displacements = [ ] if is_diagonal : directions = directions_diag else : directions = directions_axis if log_level > 2 : print ( "Site point symmetry:" ) for atom_num in symmetry . get_independe... | Return a set of displacements |
33,578 | def read_aims ( filename ) : lines = open ( filename , 'r' ) . readlines ( ) cell = [ ] is_frac = [ ] positions = [ ] symbols = [ ] magmoms = [ ] for line in lines : fields = line . split ( ) if not len ( fields ) : continue if fields [ 0 ] == "lattice_vector" : vec = lmap ( float , fields [ 1 : 4 ] ) cell . append ( v... | Method to read FHI - aims geometry files in phonopy context . |
33,579 | def write_aims ( filename , atoms ) : lines = "" lines += "# geometry.in for FHI-aims \n" lines += "# | generated by phonopy.FHIaims.write_aims() \n" lattice_vector_line = "lattice_vector " + "%16.16f " * 3 + "\n" for vec in atoms . get_cell ( ) : lines += lattice_vector_line % tuple ( vec ) N = atoms . get_number_of_a... | Method to write FHI - aims geometry files in phonopy context . |
33,580 | def read_aims_output ( filename ) : lines = open ( filename , 'r' ) . readlines ( ) l = 0 N = 0 while l < len ( lines ) : line = lines [ l ] if "| Number of atoms" in line : N = int ( line . split ( ) [ 5 ] ) elif "| Unit cell:" in line : cell = [ ] for i in range ( 3 ) : l += 1 vec = lmap ( float , lines [ l ] . split... | Read FHI - aims output and return geometry energy and forces from last self - consistency iteration |
33,581 | def find_primitive ( cell , symprec = 1e-5 ) : lattice , positions , numbers = spg . find_primitive ( cell . totuple ( ) , symprec ) if lattice is None : return None else : return Atoms ( numbers = numbers , scaled_positions = positions , cell = lattice , pbc = True ) | A primitive cell is searched in the input cell . When a primitive cell is found an object of Atoms class of the primitive cell is returned . When not None is returned . |
33,582 | def elaborate_borns_and_epsilon ( ucell , borns , epsilon , primitive_matrix = None , supercell_matrix = None , is_symmetry = True , symmetrize_tensors = False , symprec = 1e-5 ) : assert len ( borns ) == ucell . get_number_of_atoms ( ) , "num_atom %d != len(borns) %d" % ( ucell . get_number_of_atoms ( ) , len ( borns ... | Symmetrize Born effective charges and dielectric constants and extract Born effective charges of symmetrically independent atoms for primitive cell . |
33,583 | def symmetrize_borns_and_epsilon ( borns , epsilon , ucell , primitive_matrix = None , supercell_matrix = None , symprec = 1e-5 , is_symmetry = True ) : lattice = ucell . get_cell ( ) positions = ucell . get_scaled_positions ( ) u_sym = Symmetry ( ucell , is_symmetry = is_symmetry , symprec = symprec ) rotations = u_sy... | Symmetrize Born effective charges and dielectric tensor |
33,584 | def read_dftbp ( filename ) : infile = open ( filename , 'r' ) lines = infile . readlines ( ) for ss in lines : if ss . strip ( ) . startswith ( '#' ) : lines . remove ( ss ) natoms = int ( lines [ 0 ] . split ( ) [ 0 ] ) symbols = lines [ 1 ] . split ( ) if ( lines [ 0 ] . split ( ) [ 1 ] . lower ( ) == 'f' ) : is_sca... | Reads DFTB + structure files in gen format . |
33,585 | def get_reduced_symbols ( symbols ) : reduced_symbols = [ ] for ss in symbols : if not ( ss in reduced_symbols ) : reduced_symbols . append ( ss ) return reduced_symbols | Reduces expanded list of symbols . |
33,586 | def write_dftbp ( filename , atoms ) : scale_pos = dftbpToBohr lines = "" natoms = atoms . get_number_of_atoms ( ) lines += str ( natoms ) lines += ' S \n' expaned_symbols = atoms . get_chemical_symbols ( ) symbols = get_reduced_symbols ( expaned_symbols ) lines += ' ' . join ( symbols ) + '\n' atom_numbers = [ ] for s... | Writes DFTB + readable gen - formatted structure files |
33,587 | def write_supercells_with_displacements ( supercell , cells_with_disps , filename = "geo.gen" ) : write_dftbp ( filename + "S" , supercell ) for ii in range ( len ( cells_with_disps ) ) : write_dftbp ( filename + "S-{:03d}" . format ( ii + 1 ) , cells_with_disps [ ii ] ) | Writes perfect supercell and supercells with displacements |
33,588 | def get_interface_mode ( args ) : calculator_list = [ 'wien2k' , 'abinit' , 'qe' , 'elk' , 'siesta' , 'cp2k' , 'crystal' , 'vasp' , 'dftbp' , 'turbomole' ] for calculator in calculator_list : mode = "%s_mode" % calculator if mode in args and args . __dict__ [ mode ] : return calculator return None | Return calculator name |
33,589 | def get_default_physical_units ( interface_mode = None ) : from phonopy . units import ( Wien2kToTHz , AbinitToTHz , PwscfToTHz , ElkToTHz , SiestaToTHz , VaspToTHz , CP2KToTHz , CrystalToTHz , DftbpToTHz , TurbomoleToTHz , Hartree , Bohr ) units = { 'factor' : None , 'nac_factor' : None , 'distance_to_A' : None , 'for... | Return physical units used for calculators |
33,590 | def get_tetrahedra_integration_weight ( omegas , tetrahedra_omegas , function = 'I' ) : if isinstance ( omegas , float ) : return phonoc . tetrahedra_integration_weight ( omegas , np . array ( tetrahedra_omegas , dtype = 'double' , order = 'C' ) , function ) else : integration_weights = np . zeros ( len ( omegas ) , dt... | Returns integration weights |
33,591 | def _g_1 ( self ) : return ( 3 * self . _f ( 1 , 0 ) * self . _f ( 2 , 0 ) / ( self . _vertices_omegas [ 3 ] - self . _vertices_omegas [ 0 ] ) ) | omega1 < omega < omega2 |
33,592 | def _g_3 ( self ) : return ( 3 * self . _f ( 1 , 3 ) * self . _f ( 2 , 3 ) / ( self . _vertices_omegas [ 3 ] - self . _vertices_omegas [ 0 ] ) ) | omega3 < omega < omega4 |
33,593 | def deactivate_user ( self , user ) : if user . active : user . active = False return True return False | Deactivates a specified user . Returns True if a change was made . |
33,594 | def activate_user ( self , user ) : if not user . active : user . active = True return True return False | Activates a specified user . Returns True if a change was made . |
33,595 | def create_role ( self , ** kwargs ) : role = self . role_model ( ** kwargs ) return self . put ( role ) | Creates and returns a new role from the given parameters . |
33,596 | def find_or_create_role ( self , name , ** kwargs ) : kwargs [ "name" ] = name return self . find_role ( name ) or self . create_role ( ** kwargs ) | Returns a role matching the given name or creates it with any additionally provided parameters . |
33,597 | def http_auth_required ( realm ) : def decorator ( fn ) : @ wraps ( fn ) def wrapper ( * args , ** kwargs ) : if _check_http_auth ( ) : return fn ( * args , ** kwargs ) if _security . _unauthorized_callback : return _security . _unauthorized_callback ( ) else : r = _security . default_http_auth_realm if callable ( real... | Decorator that protects endpoints using Basic HTTP authentication . |
33,598 | def auth_token_required ( fn ) : @ wraps ( fn ) def decorated ( * args , ** kwargs ) : if _check_token ( ) : return fn ( * args , ** kwargs ) if _security . _unauthorized_callback : return _security . _unauthorized_callback ( ) else : return _get_unauthorized_response ( ) return decorated | Decorator that protects endpoints using token authentication . The token should be added to the request by the client by using a query string variable with a name equal to the configuration value of SECURITY_TOKEN_AUTHENTICATION_KEY or in a request header named that of the configuration value of SECURITY_TOKEN_AUTHENTI... |
33,599 | def confirm_user ( user ) : if user . confirmed_at is not None : return False user . confirmed_at = _security . datetime_factory ( ) _datastore . put ( user ) user_confirmed . send ( app . _get_current_object ( ) , user = user ) return True | Confirms the specified user |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.