Skip to content

Commit

Permalink
Merge pull request #531 from m-a-d-n-e-s-s/jpm-cleanup
Browse files Browse the repository at this point in the history
Misc. cleanup
  • Loading branch information
evaleev authored Mar 28, 2024
2 parents c406f4e + 8127e3e commit b43c123
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
10 changes: 5 additions & 5 deletions src/examples/dielectric.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,11 @@ int main(int argc, char **argv) {
print("coords", atomic_coords);

// Functors for mask related quantities
real_functor_3d volume_functor(new MolecularVolumeMask(sigma, atomic_radii, atomic_coords));
real_functor_3d gradx_functor(new MolecularVolumeMaskGrad(sigma, atomic_radii, atomic_coords, 0));
real_functor_3d grady_functor(new MolecularVolumeMaskGrad(sigma, atomic_radii, atomic_coords, 1));
real_functor_3d gradz_functor(new MolecularVolumeMaskGrad(sigma, atomic_radii, atomic_coords, 2));
real_functor_3d surface_functor(new MolecularSurface(sigma, atomic_radii, atomic_coords));
auto volume_functor = MolecularVolumeMask(sigma, atomic_radii, atomic_coords);
auto gradx_functor = MolecularVolumeMaskGrad(sigma, atomic_radii, atomic_coords, 0);
auto grady_functor = MolecularVolumeMaskGrad(sigma, atomic_radii, atomic_coords, 1);
auto gradz_functor = MolecularVolumeMaskGrad(sigma, atomic_radii, atomic_coords, 2);
auto surface_functor = MolecularSurface(sigma, atomic_radii, atomic_coords);

// Make the actual functions
TIME("make volume ", real_function_3d volume = real_factory_3d(world).functor(volume_functor));
Expand Down
16 changes: 8 additions & 8 deletions src/examples/dielectric_external_field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ int main(int argc, char **argv) {
FunctionDefaults<3>::set_bc(BC_FREE);

// The Coulomb operator (this is just 1/r ... whereas the notes are -1/4pir)
real_convolution_3d op = CoulombOperator(world, sigma*0.001, thresh*0.1);
auto op = CoulombOperator(world, sigma*0.001, thresh*0.1);

// Derivative operators
real_derivative_3d Dx = free_space_derivative<double,3>(world, 0);
real_derivative_3d Dy = free_space_derivative<double,3>(world, 1);
real_derivative_3d Dz = free_space_derivative<double,3>(world, 2);
auto Dx = free_space_derivative<double,3>(world, 0);
auto Dy = free_space_derivative<double,3>(world, 1);
auto Dz = free_space_derivative<double,3>(world, 2);

// We will have one sphere of radius R centered at the origin
vector<double> atomic_radii(1,R-delta);
Expand All @@ -169,9 +169,9 @@ int main(int argc, char **argv) {
print(MolecularVolumeExponentialSwitchLogGrad(sigma,epsilon_1,epsilon_0, atomic_radii, atomic_coords,0).special_points());

// Log derivative of the dielectric function
real_function_3d logdx = real_factory_3d(world).functor(real_functor_3d(new MolecularVolumeExponentialSwitchLogGrad(sigma,epsilon_1,epsilon_0, atomic_radii, atomic_coords,0)));
real_function_3d logdy = real_factory_3d(world).functor(real_functor_3d(new MolecularVolumeExponentialSwitchLogGrad(sigma,epsilon_1,epsilon_0, atomic_radii, atomic_coords,1)));
real_function_3d logdz = real_factory_3d(world).functor(real_functor_3d(new MolecularVolumeExponentialSwitchLogGrad(sigma,epsilon_1,epsilon_0, atomic_radii, atomic_coords,2)));
std::vector<real_function_3d> logd(3);
for (int i = 0; i < 3; i++)
logd.emplace_back(real_factory_3d(world).functor(MolecularVolumeExponentialSwitchLogGrad(sigma,epsilon_1,epsilon_0, atomic_radii, atomic_coords,i)));

//double area = 4*madness::constants::pi*R*R;
//double simulation_volume = 8*L*L*L;
Expand All @@ -186,7 +186,7 @@ int main(int argc, char **argv) {
real_function_3d surface_charge, old_surface_charge(world);
for (int iter=0; iter<20; iter++) {
// Scale with 1/4pi AFTER applying operator to get one more digit of accuracy
surface_charge = (logdx*Dx(u) + logdy*Dy(u) + logdz*(-Ez+Dz(u))).truncate();
surface_charge = (logd[0]*Dx(u) + logd[1]*Dy(u) + logd[2]*(-Ez+Dz(u))).truncate();
real_function_3d r = (u - op(surface_charge).scale(rfourpi)).truncate(thresh*0.032);
surface_charge.scale(rfourpi);

Expand Down
14 changes: 7 additions & 7 deletions src/examples/dirac-hatom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -961,12 +961,12 @@ struct ExactSpinor : public FunctionFunctorInterface<double_complex,3> {
}

void set_ansatz(const AnsatzBase& ansatz) {
compute_F = (ansatz.iansatz==3) ? true : false;
compute_F = (ansatz.iansatz == 3);
cusp_a=ansatz.get_cusp_a();
regularized= (ansatz.iansatz==0) ? false : true;
regularized= !(ansatz.iansatz == 0);
}

int l_char_to_int(const char lc) const {
static int l_char_to_int(const char lc) {
int ll=0;
if (lc=='S') ll=0;
else if (lc=='P') ll=1;
Expand Down Expand Up @@ -1323,10 +1323,10 @@ void run(World& world, ansatzT ansatz, const int nuclear_charge, const commandli
guess= schrodinger2dirac(wf,ansatz,nuclear_charge);
} else {
print("\nUsing exact spinor guess\n");
for (int i=0; i<nstates; ++i) {
states[i].set_ansatz(ansatz);
guess.push_back(states[i].get_spinor(world));
states[i].print();
for (auto& state: states) {
state.set_ansatz(ansatz);
guess.push_back(state.get_spinor(world));
state.print();
guess.back().print_norms("guess");

}
Expand Down
5 changes: 1 addition & 4 deletions src/madness/mra/mraimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1042,10 +1042,7 @@ namespace madness {
template <typename T, std::size_t NDIM>
void FunctionImpl<T,NDIM>::diff(const DerivativeBase<T,NDIM>* D, const implT* f, bool fence) {
typedef std::pair<keyT,coeffT> argT;
typename dcT::const_iterator end = f->coeffs.end();
for (typename dcT::const_iterator it=f->coeffs.begin(); it!=end; ++it) {
const keyT& key = it->first;
const nodeT& node = it->second;
for (const auto& [key, node]: f->coeffs) {
if (node.has_coeff()) {
Future<argT> left = D->find_neighbor(f, key,-1);
argT center(key,node.coeff());
Expand Down

0 comments on commit b43c123

Please sign in to comment.