|
| 1 | +/* pcmsolver_copyright_start */ |
| 2 | +/* |
| 3 | + * PCMSolver, an API for the Polarizable Continuum Model |
| 4 | + * Copyright (C) 2013 Roberto Di Remigio, Luca Frediani and contributors |
| 5 | + * |
| 6 | + * This file is part of PCMSolver. |
| 7 | + * |
| 8 | + * PCMSolver is free software: you can redistribute it and/or modify |
| 9 | + * it under the terms of the GNU Lesser General Public License as published by |
| 10 | + * the Free Software Foundation, either version 3 of the License, or |
| 11 | + * (at your option) any later version. |
| 12 | + * |
| 13 | + * PCMSolver is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * GNU Lesser General Public License for more details. |
| 17 | + * |
| 18 | + * You should have received a copy of the GNU Lesser General Public License |
| 19 | + * along with PCMSolver. If not, see <http://www.gnu.org/licenses/>. |
| 20 | + * |
| 21 | + * For information on the complete list of contributors to the |
| 22 | + * PCMSolver API, see: <http://pcmsolver.github.io/pcmsolver-doc> |
| 23 | + */ |
| 24 | +/* pcmsolver_copyright_end */ |
| 25 | + |
| 26 | +#include <iostream> |
| 27 | +#include <iomanip> |
| 28 | +#include <fstream> |
| 29 | +#include <string> |
| 30 | + |
| 31 | +#include "Config.hpp" |
| 32 | + |
| 33 | +#include <Eigen/Dense> |
| 34 | + |
| 35 | +#include "DerivativeTypes.hpp" |
| 36 | +#include "PWCSolver.hpp" |
| 37 | +#include "UniformDielectric.hpp" |
| 38 | +#include "Vacuum.hpp" |
| 39 | +#include "WaveletCavity.hpp" |
| 40 | +#include "PhysicalConstants.hpp" |
| 41 | + |
| 42 | +void pwc_C6H6(); |
| 43 | + |
| 44 | +int main() { |
| 45 | + pwc_C6H6(); |
| 46 | +} |
| 47 | + |
| 48 | +void pwc_C6H6() |
| 49 | +{ |
| 50 | + // Molecular geometry. These coordinates are in Angstrom! |
| 51 | + Eigen::Vector3d C1( 5.274, 1.999, -8.568); |
| 52 | + Eigen::Vector3d C2( 6.627, 2.018, -8.209); |
| 53 | + Eigen::Vector3d C3( 7.366, 0.829, -8.202); |
| 54 | + Eigen::Vector3d C4( 6.752, -0.379, -8.554); |
| 55 | + Eigen::Vector3d C5( 5.399, -0.398, -8.912); |
| 56 | + Eigen::Vector3d C6( 4.660, 0.791, -8.919); |
| 57 | + Eigen::Vector3d H1( 4.704, 2.916, -8.573); |
| 58 | + Eigen::Vector3d H2( 7.101, 2.950, -7.938); |
| 59 | + Eigen::Vector3d H3( 8.410, 0.844, -7.926); |
| 60 | + Eigen::Vector3d H4( 7.322, -1.296, -8.548); |
| 61 | + Eigen::Vector3d H5( 4.925, -1.330, -9.183); |
| 62 | + Eigen::Vector3d H6( 3.616, 0.776, -9.196); |
| 63 | + // Set up cavity, read it from Maharavo's file benzene2.dat |
| 64 | + WaveletCavity cavity("benzene2.dat"); |
| 65 | + cavity.scaleCavity(1./convertBohrToAngstrom); |
| 66 | + |
| 67 | + double permittivity = 78.39; |
| 68 | + double Hcharge = 1.0; |
| 69 | + double Ccharge = 6.0; |
| 70 | + double totalASC = - (6 * Ccharge + 6 * Hcharge) * ( permittivity - 1) / permittivity; |
| 71 | + |
| 72 | + Vacuum<AD_directional> * gfInside = new Vacuum<AD_directional>(); |
| 73 | + UniformDielectric<AD_directional> * gfOutside = new |
| 74 | + UniformDielectric<AD_directional>(permittivity); |
| 75 | + int firstKind = 0; |
| 76 | +#ifdef DEBUG |
| 77 | + FILE* debugFile = fopen("debug.out","w"); |
| 78 | + fclose(debugFile); |
| 79 | +#endif |
| 80 | + PWCSolver solver(gfInside, gfOutside, firstKind); |
| 81 | + solver.buildSystemMatrix(cavity); |
| 82 | + cavity.uploadPoints(solver.getQuadratureLevel(), solver.getT_()); |
| 83 | + |
| 84 | + int size = cavity.size(); |
| 85 | + Eigen::VectorXd fake_mep = Eigen::VectorXd::Zero(size); |
| 86 | + for (int i = 0; i < size; ++i) { |
| 87 | + Eigen::Vector3d center = cavity.elementCenter(i); |
| 88 | + double C1mep = Ccharge/(center - C1/convertBohrToAngstrom).norm(); |
| 89 | + double C2mep = Ccharge/(center - C2/convertBohrToAngstrom).norm(); |
| 90 | + double C3mep = Ccharge/(center - C3/convertBohrToAngstrom).norm(); |
| 91 | + double C4mep = Ccharge/(center - C4/convertBohrToAngstrom).norm(); |
| 92 | + double C5mep = Ccharge/(center - C5/convertBohrToAngstrom).norm(); |
| 93 | + double C6mep = Ccharge/(center - C6/convertBohrToAngstrom).norm(); |
| 94 | + |
| 95 | + double H1mep = Hcharge/(center - H1/convertBohrToAngstrom).norm(); |
| 96 | + double H2mep = Hcharge/(center - H2/convertBohrToAngstrom).norm(); |
| 97 | + double H3mep = Hcharge/(center - H3/convertBohrToAngstrom).norm(); |
| 98 | + double H4mep = Hcharge/(center - H4/convertBohrToAngstrom).norm(); |
| 99 | + double H5mep = Hcharge/(center - H5/convertBohrToAngstrom).norm(); |
| 100 | + double H6mep = Hcharge/(center - H6/convertBohrToAngstrom).norm(); |
| 101 | + fake_mep(i) = C1mep + C2mep + C3mep + C4mep + C5mep + C6mep + |
| 102 | + H1mep + H2mep + H3mep + H4mep + H5mep + H6mep; |
| 103 | + } |
| 104 | + // The total ASC for a dielectric is -Q*[(epsilon-1)/epsilon] |
| 105 | + Eigen::VectorXd fake_asc = Eigen::VectorXd::Zero(size); |
| 106 | + solver.compCharge(fake_mep, fake_asc); |
| 107 | + double totalFakeASC = fake_asc.sum(); |
| 108 | + |
| 109 | + double energy = 0.5 * (fake_mep.dot(fake_asc)); |
| 110 | + |
| 111 | + std::ofstream report; |
| 112 | + report.open("pwc_C6H6_report.out", std::ios::out); |
| 113 | + report << " Piecewise constant wavelet solver, C6H6 molecule " << std::endl; |
| 114 | + report << cavity << std::endl; |
| 115 | + report << "------------------------------------------------------------" << std::endl; |
| 116 | + report << "totalASC = " << std::setprecision(20) << totalASC << std::endl; |
| 117 | + report << "totalFakeASC = " << std::setprecision(20) << totalFakeASC << std::endl; |
| 118 | + report << "Delta = " << std::setprecision(20) << totalASC - totalFakeASC << std::endl; |
| 119 | + report << "Energy = " << std::setprecision(20) << energy << std::endl; |
| 120 | + report << "------------------------------------------------------------" << std::endl; |
| 121 | + report.close(); |
| 122 | +} |
0 commit comments