Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ build
external/lbfgs/lbfgs_um
pyrofess/__pycache__
test/__pycache__
website/source/user-guide/generated
website/build
.ipynb_checkpoints
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ target_include_directories(profess PUBLIC ${LIBXC_INCLUDE_DIR})
target_link_directories(profess PUBLIC ${LIBXC_LIBRARY_DIR})
target_link_libraries(profess PUBLIC xc)

# pyrofess
pybind11_add_module(pyrofess MODULE pyrofess/pyrofess.cpp)
target_link_libraries(pyrofess PUBLIC profess)
# profess-pybind
pybind11_add_module(profess-pybind MODULE pyrofess/pyrofess.cpp)
target_link_libraries(profess-pybind PUBLIC profess)
set_target_properties(profess-pybind PROPERTIES OUTPUT_NAME profess)

# pyrofess extras
# profess-pybind extras
pybind11_add_module(extras MODULE pyrofess/extras.cpp)
target_link_libraries(extras PUBLIC profess)
2 changes: 1 addition & 1 deletion external/ase
Submodule ase updated from 17c53a to d626b2
2 changes: 1 addition & 1 deletion include/ions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Ions
std::vector<std::function<double(double)>>
ft_potential_derivatives();

Ions& add_ion_type_coulomb(double z);
Ions& add_ion_type_coulomb(double z, double cutoff=-1.0);
Ions& add_ion_type_recpot(std::string filename);
Ions& add_ion_type_harmonic_compactified(double w, double r1, double r2);
Ions& add_ion_type_generic(
Expand Down
49 changes: 32 additions & 17 deletions include/system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,22 @@ namespace profess

class System
{
public:

public:
// public constructors (named constructor idiom)
static
System create(
std::array<std::array<double,3>,3> box_vectors,
double energy_cutoff,
std::array<std::string,2> units={"b","h"});
static
System create_from_grid_shape(
std::array<std::array<double,3>,3> box_vectors,
std::array<size_t,3> grid_shape,
std::string unit={"b"});
private:
System(std::array<size_t,3> grid_shape);

static std::array<size_t,3> get_shape(
std::array<std::array<double,3>,3> box_vectors,
double energy_cutoff,
std::array<std::string,2> units={"b","h"});

public:
// rule of five
// copy construction/assignment disabled b/c class has unique ptrs
~System() = default;
Expand All @@ -47,7 +54,8 @@ class System
System& add_coulomb_ions(
double z,
std::vector<std::array<double,3>> coords,
std::string unit={"b"});
std::string unit={"b"},
double cutoff=-1.0);
System& add_harmonic_ions();

std::vector<std::array<double,3>> ions_xyz_coords(std::string unit);
Expand All @@ -57,29 +65,31 @@ class System
System& add_ion_electron_functional();
System& add_luo_karasiev_trickey_functional(double a=1.3,
double tiny_den=1e-12);
System& add_libxc_functional(std::vector<int>);
System& add_kinetic_class_a_functional(
System& add_libxc_functional(std::vector<int> xc_func_ids);
System& add_generic_nonlocal_a_functional(
double a,
double b,
std::function<double(double)> f,
std::function<double(double)> fp,
double den0);
double den0=-1);
System& add_perdew_burke_ernzerhof_functional();
System& add_perdew_zunger_functional();
System& add_perrot_functional(double den0);
System& add_smargiassi_madden_functional(double den0);
System& add_perrot_functional(double den0=-1.0);
System& add_smargiassi_madden_functional(double den0=-1.0);
System& add_thomas_fermi_functional();
System& add_wang_govind_carter_functional(
double den0,
double den0=-1.0,
double alpha=(5.0+std::sqrt(5.0))/6.0,
double beta=(5.0-std::sqrt(5.0))/6.0,
double gamma=2.7);
System& add_wang_govind_carter_1999_i_functional(double den0);
System& add_wang_teter_functional(double den0);
System& add_wang_govind_carter_1999_i_functional(double den0=-1.0);
System& add_wang_teter_functional(double den0=-1.0);
System& add_weizsaecker_functional();

System& remove_functional(std::string name);

System& add_ion_ion_interaction();

// basic information about the system
double energy(std::string unit={"h"});
std::tuple<double, Double3D> energy_potential(bool compute_ion_ion=true);
Expand All @@ -89,9 +99,10 @@ class System
double pressure(std::string unit={"h/b3"});
double enthalpy(std::string unit={"h"});
double energy_cutoff(std::string unit={"h"});
double total_ion_charge();

// basic manipulations
System& distribute_electrons_uniformly(const double electrons);
System& add_electrons(double electrons=-1.0);
System& move_ions(
std::vector<std::array<double,3>> xyz_coords,
std::string length_unit={"b"});
Expand All @@ -110,6 +121,10 @@ class System
double energy_tol=1e-5,
size_t window_size=3,
size_t max_iter=100);

private:

bool _ion_ion_interaction = false;
};

}
12 changes: 6 additions & 6 deletions pyrofess/ase_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def init_optimizer(atoms, algorithm):
return optimizer

def minimize_forces(system, algorithm, fmax=1e-4, steps=100):
atoms = Atoms('H' + str(system.ions.count()),
positions=system.ions.xyz_coords(),
atoms = Atoms('H' + str(len(system.ions_xyz_coords())),
positions=system.ions_xyz_coords(),
cell=system.box_vectors(),
pbc=True)
atoms.calc = Profess(system)
Expand All @@ -44,8 +44,8 @@ def minimize_stress(
hydrostatic_strain=False,
constant_volume=False,
scalar_pressure=0.0):
atoms = Atoms('H' + str(system.ions.count()),
positions=system.ions.xyz_coords(),
atoms = Atoms('H' + str(len(system.ions_xyz_coords())),
positions=system.ions_xyz_coords(),
cell=system.box_vectors(),
pbc=True)
atoms.calc = Profess(system)
Expand All @@ -67,7 +67,7 @@ def minimize_forces_stress(
hydrostatic_strain=False,
constant_volume=False,
scalar_pressure=0.0):
atoms = Atoms('H' + str(system.ions.count()),
atoms = Atoms('H' + str(len(system.ions_xyz_coords())),
positions=system.ions_xyz_coords(),
cell=system.box_vectors(),
pbc=True)
Expand Down Expand Up @@ -102,4 +102,4 @@ def optimize_geometry(init_system, box_vectors, xyz_coords, energy_cutoff):
return system
else:
box_vectors = np.array(system.box.vectors()).T
xyz_coords = np.array(system.ions.xyz_coords())
xyz_coords = np.array(system.ions_xyz_coords())
Loading