pychemia.population package

Submodules

pychemia.population.ljcluster module

class pychemia.population.ljcluster.LJCluster(name, composition=None, tag='global', target_forces=0.001, value_tol=0.01, distance_tol=0.1, minimal_density=70.0, refine=True, direct_evaluation=False)[source]

Bases: pychemia.population._population.Population

add_random()[source]

Add one random structure to the population

check_duplicates(ids)[source]
cross(ids)[source]
distance(entry_id, entry_jd, rcut=50)[source]

Return a measure of the distance between two clusters by computing a n-dimensional vector of the distances between each atom to the origin and

Parameters:
  • rcut
  • entry_id – The id of one population entry
  • entry_jd – The id of another population entry
Returns:

(int) The distance between two clusters

evaluate(structure, gtol=None)[source]
evaluate_entry(entry_id)[source]
from_dict(population_dict)[source]
get_duplicates(ids, fast=False)[source]
get_forces(entry_id)[source]
get_structure(entry_id)[source]
is_evaluated(entry_id)[source]
maxforce(entry_id)[source]
move(entry_id, entry_jd, factor=0.2, in_place=False)[source]
move_random(entry_id, factor=0.2, in_place=False, kind='move')[source]
new_entry(structure, active=True)[source]
recover()[source]
refine(entry_id, gtol=None)[source]
refine_progressive(entry_id)[source]
str_entry(entry_id)[source]
to_dict
value(entry_id)[source]
pychemia.population.ljcluster.direct_move(pos_orig, pos_dest, fraction)[source]
pychemia.population.ljcluster.movement_sweep(pos_orig, pos_dest, symbols, figname='figure.pdf')[source]
pychemia.population.ljcluster.rotation_move(pos_orig, pos_dest, fraction)[source]

pychemia.population.noncollinearmagmoms module

class pychemia.population.noncollinearmagmoms.NonCollinearMagMoms(name, source_dir='.', mag_atoms=None, magmom_magnitude=2.0, distance_tolerance=0.1, incar_extra=None, debug=False)[source]

Bases: pychemia.population._population.Population

add_random()[source]

Creates a new candidate with random orientiations for the magnetic moments of all the atoms in ‘mag_atoms’

Returns:
check_duplicates(ids)[source]

Returns a dictionary of non-equivalent candidates as keys and associated to each key the list of candidates whose distance is less that the ‘distance_tolerance’ argument.

Parameters:ids
Returns:
collect_data(entry_id, workdir)[source]
cross(ids)[source]
debug_evaluation(magmom_sph)[source]

For debugging ONLY: Fake evaluation of total energy using a magnetic configuration as the minimal energy, the numerical distance with other candidates defines their energy.

Parameters:magmom_sph
Returns:
distance(entry_id, entry_jd)[source]

Compute the distance between 2 candidates as the average angular movement between the magnetic moments for all the atoms considered magnetic (‘mag_atoms’)

Parameters:
  • entry_id
  • entry_jd
Returns:

evaluate_entry(entry_id)[source]
static from_dict(population_dict)[source]
get_duplicates(ids)[source]
is_evaluated(entry_id)[source]

One candidate is considered evaluated if it contains any finite value of energy on the properties.energy field

Parameters:entry_id
Returns:
move(entry_id, entry_jd, factor=0.2, in_place=False)[source]

Move the magnetic moments from one candidate in the direction of another.

Parameters:
  • entry_id – Source candidate, this one will be moved
  • entry_jd – Destination candidate, this one is not moved.
  • factor – (float) a value in range [0,1] 0 being the source, 1 the destination
  • in_place – (bool) if true the new magnetic moments replace those in entry_id
Returns:

move_random(entry_id, factor=0.2, in_place=False, kind='move')[source]

Change the magnetic orientation randomly for all the atoms considered magnetic ‘mag_atoms’ The ‘factor’ argument scales the intensite of the movement.

Parameters:
  • entry_id
  • factor
  • in_place
  • kind
Returns:

new_entry(cartesian_magmoms, active=True)[source]

Creates a new entry on the database

Parameters:
  • cartesian_magmoms – Magnetic moments stored in spherical coordinates
  • active
Returns:

prepare_folder(entry_id, workdir, binary='vasp', source_dir='.')[source]
recover()[source]
str_entry(entry_id)[source]
to_dict
value(entry_id)[source]

Return the energy value associated to the candidate with identifier ‘entry_id’

Parameters:entry_id
Returns:

pychemia.population.orbitaldftu module

class pychemia.population.orbitaldftu.OrbitalDFTU(name, input_path='abinit.in', num_electrons_dftu=None, num_indep_matrices=None, connections=None)[source]

Bases: pychemia.population._population.Population

add_random()[source]

Creates a new set of variables to reconstruct the dmatpawu

matrix_i (integers) is a matrix natpawu x ndim with entries are 0 or 1 matrix_d (deltas) is a matrix natpawu x ndim with entries are [0, 0.5) P (matrices) is a set of matrices natpawu x ndim x ndim Those three matrices allow to reconstruct the variable ‘dmatpawu’ used by ABINIT

Returns:
check_duplicates(ids)[source]
For a given list of identifiers ‘ids’ checks the values for the function ‘distance’ and return a dictionary
where each key is the identifier of a unique candidate and the value is a list of identifiers considered equivalents to it.
Parameters:ids – List of identifiers for wich the check will be performed
Returns:
collect_data(entry_id, workdir)[source]
cross(ids)[source]

Crossing algorithm used notably by GA to mix the information from several candidates This crossing algorithm is mixing the angles of two correlation matrices preserving the ordering of the atoms where the angles are applied. The occupations and deltas are also mixed independently of the euler angles.

Parameters:ids
Returns:
distance(entry_id, entry_jd)[source]

Measure of distance for two entries with identifiers ‘entry_id’ and ‘entry_jd’

Parameters:
  • entry_id – Identifier of first entry
  • entry_jd – Identifier of second entry
Returns:

evaluate_entry(entry_id)[source]

Evaluation externalized, no implemented

Parameters:entry_id
Returns:
from_dict(population_dict)[source]
get_correlation_params(entry_id)[source]
get_duplicates(ids)[source]
is_evaluated(entry_id)[source]

One candidate is considered evaluated if it contains any finite value of energy on the properties.energy field

Parameters:entry_id
Returns:
move(entry_id, entry_jd, factor=0.2, in_place=False)[source]

Move one candidate with identifier ‘entry_id’ in the direction of another candidate ‘entry_jd’

Parameters:
  • entry_id – Identifier of first entry (Origin)
  • entry_jd – Identifier of second entry (Target)
  • factor – Scale factor for change, 0 scale is the ‘Origin’ candidate, 1 is the ‘Target’ candidate Intermediate values will change candidates accordingly
  • in_place – If True the candidate is changed keeping the identifier unchanged
Returns:

move_random(entry_id, factor=0.2, in_place=False, kind='move')[source]

Move one candidate with identifier ‘entry_id’ randomly with a factor given by ‘factor’

Parameters:
  • entry_id – Identifier of entry
  • factor – Factor use to scale the randomness of change
  • in_place – If True the candidate is changed keeping the identifier unchanged
  • kind – Use when several algorithms are used for movement. One implemented here
Returns:

ndim

Dimension of the matrices defined on dmatpawu, for ‘d’ orbitals is 5 for ‘f’ orbitals is 7

Returns:
new_entry(properties, active=True)[source]

Creates a new entry on the population database from given data.

Parameters:
  • properties – dictionary with 3 keys ‘D’ for deltas, ‘I’ for the integers and eigen for the rotation matrix applied to the orbitals
  • active – if True, the entry is enabled on the DB to be evaluated.
Returns:

prepare_folder(entry_id, workdir='.', source_dir='.')[source]

Prepare directories for abinit execution

Parameters:
  • entry_id – bson.ObjectID of the entry that will be used for preparing the folder
  • source_dir – (str) is the directory where ‘abinit.files’ and ‘batch.pbs’ should be present those directories will be symbolically linked inside the individual work directories
  • workdir – (str) Base work directory for abinit executions. Inside this directory, a set of subdirectories will be created using the mongo ID as name.
recover()[source]
str_entry(entry_id)[source]
to_dict
value(entry_id)[source]

Return the energy value associated to the candidate with identifier ‘entry_id’

Parameters:entry_id
Returns:
pychemia.population.orbitaldftu.dmatpawu2params(dmatpawu, ndim)[source]

Takes the contents of the variable ‘dmatpawu’ and return their components as a set of ‘occupations’, ‘deltas’ and ‘euler_angles’ The Euler angles is a ordered list of angles that can rebuild a rotation matrix ‘R’ The rotation matrix ‘R’ is ensured to be an element of SO(ndim), ie det(R)=1. When the eigenvectors return a matrix with determinant -1 a mirror on the first dimension is applied. Such condition has no effect on the physical result of the correlation matrix

Parameters:
  • dmatpawu – The contents of the variable ‘dmatpawu’. A list of number representing N matrices ndim x ndim
  • ndim – ndim is 5 for ‘d’ orbitals and 7 for ‘f’ orbitals
Returns:

pychemia.population.orbitaldftu.get_final_correlation_matrices_from_output(filename)[source]
pychemia.population.orbitaldftu.get_final_dmatpawu(filename)[source]
pychemia.population.orbitaldftu.get_pattern(params, ndim)[source]
Parameters:
  • params
  • ndim
Returns:

pychemia.population.orbitaldftu.params2dmatpawu(params)[source]

Build the variable dmatpawu from the components stored in params

Parameters:params – dictionary with keys ‘I’, ‘D’ and ‘eigen’
Returns:

pychemia.population.realfunction module

class pychemia.population.realfunction.RealFunction(function, ndim, limits, local_minimization=False)[source]

Bases: pychemia.population._population.Population

actives
add_random()[source]
check_duplicates(ids)[source]
coordinate(i)[source]
cross(ids)[source]
disable(ident)[source]
distance(imember, jmember)[source]
enable(ident)[source]
evaluate()[source]
evaluate_entry(ident)[source]
from_dict(population_dict)[source]
get_duplicates(ids)[source]
get_values(selection)[source]
is_evaluated(i)[source]
is_inside(x)[source]
member_str(imember)[source]
members
move(imember, jmember, factor=0.2, in_place=False)[source]

Moves imember in the direction of jmember If in_place is True the movement occurs on the same address as imember

Parameters:
  • factor
  • imember
  • jmember
  • in_place
Returns:

move_random(imember, factor=0.2, in_place=False, kind='move')[source]
new_entry(data, active=True)[source]
static new_identifier()[source]
random_population(n)[source]
recover()[source]
replace_failed()[source]
save()[source]
save_info()[source]
set_value(i, y)[source]
str_entry(entry_id)[source]
value(imember)[source]
write_change(change)[source]

pychemia.population.relaxstructures module

class pychemia.population.relaxstructures.RelaxStructures(name, composition=None, tag='global', target_forces=0.001, value_tol=0.01, distance_tol=0.3, min_comp_mult=2, max_comp_mult=8, pcdb_source=None, pressure=0.0, target_stress=None, target_diag_stress=None, target_nondiag_stress=None)[source]

Bases: pychemia.population._population.Population

add_from_db(db_settings, sizemax=1)[source]
add_random(random_probability=0.3)[source]

Add one random structure to the population

check_duplicates(ids)[source]

Computes duplicate structures measuring its distance when their value is larger than value_tol. If the distance is lower than ‘distance_tol’ the structures will be cosidered as duplicates.

Parameters:ids
Returns:(dict) Dictionary of duplicates, the keys are the ids of the duplicates and the value is the structure from which the structure is duplicated. In general the energy of the ‘value’ is lower than the ‘key’
cleaned_from_duplicates(ids)[source]
cross(ids)[source]
diff_values_matrix()[source]
distance(entry_id, entry_jd, rcut=50)[source]
distance_matrix(ids)[source]
evaluate_entry(entry_id)[source]
from_dict(population_dict)[source]
get_duplicates(ids, fast=False)[source]
get_max_force_stress(entry_id)[source]
get_structure(entry_id)[source]
is_evaluated(entry_id)[source]
move(entry_id, entry_jd, factor=0.2, in_place=False)[source]

Moves entry_id in the direction of entry_jd If in_place is True the movement occurs on the same address as entry_id

Parameters:
  • factor
  • entry_id
  • entry_jd
  • in_place
Returns:

move_random(entry_id, factor=0.2, in_place=False, kind='move')[source]
new_entry(structure, active=True)[source]
static new_identifier()[source]
recover()[source]
str_entry(entry_id)[source]
to_dict
value(entry_id)[source]