diff --git a/src/apps/cis/cis.cpp b/src/apps/cis/cis.cpp index 3b409d75c61..65d377828fc 100644 --- a/src/apps/cis/cis.cpp +++ b/src/apps/cis/cis.cpp @@ -6,7 +6,7 @@ */ #include -#include +#include #include #include diff --git a/src/apps/moldft/moldft.cc b/src/apps/moldft/moldft.cc index e194e9b3437..daa2f3315ca 100644 --- a/src/apps/moldft/moldft.cc +++ b/src/apps/moldft/moldft.cc @@ -37,7 +37,7 @@ /// \defgroup moldft The molecular density functional and Hartree-Fock code #include -#include +#include"madness/mra/commandlineparser.h" #include #include #include diff --git a/src/apps/molresponse/response_parameters.h b/src/apps/molresponse/response_parameters.h index 4ac253902c9..07c1e0a4fed 100644 --- a/src/apps/molresponse/response_parameters.h +++ b/src/apps/molresponse/response_parameters.h @@ -6,7 +6,7 @@ #ifndef SRC_APPS_MOLRESPONSE_RESPONSE_PARAMETERS_H_ #define SRC_APPS_MOLRESPONSE_RESPONSE_PARAMETERS_H_ -#include +#include "madness/mra/QCCalculationParametersBase.h" #include #include #include diff --git a/src/apps/plot/plot2cube.cpp b/src/apps/plot/plot2cube.cpp index 9e1e5675b5a..ac459881487 100644 --- a/src/apps/plot/plot2cube.cpp +++ b/src/apps/plot/plot2cube.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include "madness/mra/commandlineparser.h" #include #include diff --git a/src/apps/plot/plot2plane.cpp b/src/apps/plot/plot2plane.cpp index 74e6b6b9872..fa9d4379e3e 100644 --- a/src/apps/plot/plot2plane.cpp +++ b/src/apps/plot/plot2plane.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include "madness/mra/commandlineparser.h" #include #include diff --git a/src/examples/density_smoothing.cc b/src/examples/density_smoothing.cc index 6f3f735e542..4dda2cc995f 100644 --- a/src/examples/density_smoothing.cc +++ b/src/examples/density_smoothing.cc @@ -40,7 +40,7 @@ */ #include "smooth.h" -#include +#include"madness/mra/commandlineparser.h" #include diff --git a/src/examples/helium_exact.cc b/src/examples/helium_exact.cc index 9c307928af5..2df81da59c4 100644 --- a/src/examples/helium_exact.cc +++ b/src/examples/helium_exact.cc @@ -51,7 +51,7 @@ #include #include #include -#include +#include"madness/mra/commandlineparser.h" // switch the electronic interaction on or off diff --git a/src/madchem.h b/src/madchem.h index 3715cfc7d4f..c0af0f096ff 100644 --- a/src/madchem.h +++ b/src/madchem.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include"madness/mra/QCCalculationParametersBase.h" #include #include #include @@ -38,7 +38,7 @@ #include #include #include -#include +#include"madness/mra/commandlineparser.h" #include #include #include diff --git a/src/madness/chem/CC2.cc b/src/madness/chem/CC2.cc index c5928267578..f3ddd78e8db 100644 --- a/src/madness/chem/CC2.cc +++ b/src/madness/chem/CC2.cc @@ -7,7 +7,7 @@ #include -#include +#include #include "MolecularOrbitals.h" #include "localizer.h" diff --git a/src/madness/chem/CCStructures.h b/src/madness/chem/CCStructures.h index 10f44cf5351..13bd019ab82 100644 --- a/src/madness/chem/CCStructures.h +++ b/src/madness/chem/CCStructures.h @@ -11,9 +11,9 @@ #define CCSTRUCTURES_H_ #include -#include +#include #include -#include +#include #include #include #include diff --git a/src/madness/chem/CMakeLists.txt b/src/madness/chem/CMakeLists.txt index d42b967967b..9cb9cc0298c 100644 --- a/src/madness/chem/CMakeLists.txt +++ b/src/madness/chem/CMakeLists.txt @@ -13,7 +13,6 @@ set(MADCHEM_HEADERS ccpairfunction.h CCPotentials.h CCStructures.h - commandlineparser.h corepotential.h correlationfactor.h diamagneticpotentialfactor.h @@ -49,7 +48,6 @@ set(MADCHEM_HEADERS polynomial.h potentialmanager.h projector.h - QCCalculationParametersBase.h QCPropertyInterface.h SCF.h SCFOperators.h @@ -88,7 +86,6 @@ set(MADCHEM_SOURCES pcm.cc pointgroupsymmetry.cc polynomial.cc - QCCalculationParametersBase.cc SCF.cc SCFOperators.cc TDHF.cc @@ -143,7 +140,7 @@ if(BUILD_TESTING) SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # The list of unit test source files set(CHEM_TEST_SOURCES_SHORT test_pointgroupsymmetry.cc test_masks_and_boxes.cc - test_QCCalculationParametersBase.cc test_qc.cc test_MolecularOrbitals.cc test_BSHApply.cc) + test_qc.cc test_MolecularOrbitals.cc test_BSHApply.cc) set(CHEM_TEST_SOURCES_LONG test_localizer.cc test_ccpairfunction.cc test_low_rank_function.cc) if (LIBXC_FOUND) list(APPEND CHEM_TEST_SOURCES_SHORT test_dft.cc ) diff --git a/src/madness/chem/CalculationParameters.h b/src/madness/chem/CalculationParameters.h index 4a69d23dc9d..4f83cfcc1c0 100644 --- a/src/madness/chem/CalculationParameters.h +++ b/src/madness/chem/CalculationParameters.h @@ -42,8 +42,8 @@ #include #include -#include -#include +#include +#include namespace madness { diff --git a/src/madness/chem/SCF.h b/src/madness/chem/SCF.h index 1193fd73dcd..2e284fdd593 100644 --- a/src/madness/chem/SCF.h +++ b/src/madness/chem/SCF.h @@ -46,7 +46,7 @@ #include #include -#include +#include"madness/mra/commandlineparser.h" #include #include #include diff --git a/src/madness/chem/TDHF.cc b/src/madness/chem/TDHF.cc index e2b36c01eeb..764896ece0b 100644 --- a/src/madness/chem/TDHF.cc +++ b/src/madness/chem/TDHF.cc @@ -10,7 +10,7 @@ #include #include #include -#include +#include"madness/mra/commandlineparser.h" namespace madness { diff --git a/src/madness/chem/TDHF.h b/src/madness/chem/TDHF.h index 50bbf310ba7..c74c2859c30 100644 --- a/src/madness/chem/TDHF.h +++ b/src/madness/chem/TDHF.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include"madness/mra/commandlineparser.h" namespace madness { diff --git a/src/madness/chem/ccpairfunction.h b/src/madness/chem/ccpairfunction.h index faa7e202f04..32d13fc2e60 100644 --- a/src/madness/chem/ccpairfunction.h +++ b/src/madness/chem/ccpairfunction.h @@ -8,8 +8,8 @@ #include -#include -#include +#include +#include #include #include #include diff --git a/src/madness/chem/molecular_optimizer.h b/src/madness/chem/molecular_optimizer.h index c0aed52ad31..683c2e9e223 100644 --- a/src/madness/chem/molecular_optimizer.h +++ b/src/madness/chem/molecular_optimizer.h @@ -38,7 +38,7 @@ #include #include -#include +#include"madness/mra/QCCalculationParametersBase.h" namespace madness { diff --git a/src/madness/chem/molecule.cc b/src/madness/chem/molecule.cc index e8ad261ea44..b3c9bc857b5 100644 --- a/src/madness/chem/molecule.cc +++ b/src/madness/chem/molecule.cc @@ -459,7 +459,7 @@ nlohmann::json Molecule::to_json() const { mol_schema["symbols"] = {}; mol_schema["geometry"] = {}; - get_atomic_data(atoms[0].atomic_number).symbol; +// get_atomic_data(atoms[0].atomic_number).symbol; for (size_t i = 0; i < natom(); ++i) { mol_schema["symbols"].push_back(get_atomic_data(atoms[i].atomic_number).symbol); mol_schema["geometry"].push_back({atoms[i].x, atoms[i].y, atoms[i].z}); diff --git a/src/madness/chem/molecule.h b/src/madness/chem/molecule.h index 989a989090b..4a575273bb4 100644 --- a/src/madness/chem/molecule.h +++ b/src/madness/chem/molecule.h @@ -37,8 +37,8 @@ #include #include -#include -#include +#include"madness/mra/commandlineparser.h" +#include"madness/mra/QCCalculationParametersBase.h" #include #include #include diff --git a/src/madness/chem/mp2.h b/src/madness/chem/mp2.h index 2f1656b9861..b60844703f5 100644 --- a/src/madness/chem/mp2.h +++ b/src/madness/chem/mp2.h @@ -41,7 +41,7 @@ #include #include -#include +#include"madness/mra/QCCalculationParametersBase.h" #include #include #include diff --git a/src/madness/chem/nemo.h b/src/madness/chem/nemo.h index 72a8b2cd558..5e3093e2f4f 100644 --- a/src/madness/chem/nemo.h +++ b/src/madness/chem/nemo.h @@ -56,7 +56,7 @@ #include #include #include -#include +#include"madness/mra/commandlineparser.h" #include #include diff --git a/src/madness/chem/znemo.h b/src/madness/chem/znemo.h index 3a822f1b2d3..5c11a04029e 100644 --- a/src/madness/chem/znemo.h +++ b/src/madness/chem/znemo.h @@ -10,7 +10,7 @@ #include #include -#include +#include "madness/mra/QCCalculationParametersBase.h" #include #include #include diff --git a/src/madness/mra/CMakeLists.txt b/src/madness/mra/CMakeLists.txt index e0ec36cb333..e11342910c2 100644 --- a/src/madness/mra/CMakeLists.txt +++ b/src/madness/mra/CMakeLists.txt @@ -9,10 +9,11 @@ set(MADMRA_HEADERS mraimpl.h funcplot.h function_common_data.h function_factory.h function_interface.h gfit.h convolution1d.h simplecache.h derivative.h displacements.h functypedefs.h sdf_shape_3D.h sdf_domainmask.h vmra1.h - leafop.h nonlinsol.h macrotaskq.h macrotaskpartitioner.h) + leafop.h nonlinsol.h macrotaskq.h macrotaskpartitioner.h QCCalculationParametersBase.h + commandlineparser.h) set(MADMRA_SOURCES mra1.cc mra2.cc mra3.cc mra4.cc mra5.cc mra6.cc startup.cc legendre.cc - twoscale.cc qmprop.cc) + twoscale.cc qmprop.cc QCCalculationParametersBase.cc) # Create the MADmra library add_mad_library(mra MADMRA_SOURCES MADMRA_HEADERS "linalg;tinyxml;muparser" "madness/mra") @@ -36,7 +37,7 @@ if(BUILD_TESTING) set(MRA_TEST_SOURCES testbsh.cc testproj.cc testpdiff.cc testdiff1Db.cc testgconv.cc testopdir.cc testinnerext.cc testgaxpyext.cc testvmra.cc, test_vectormacrotask.cc test_cloud.cc - test_macrotaskpartitioner.cc) + test_macrotaskpartitioner.cc test_QCCalculationParametersBase.cc) add_unittests(mra "${MRA_TEST_SOURCES}" "MADmra;MADgtest" "unittests;short") set(MRA_SEPOP_TEST_SOURCES testsuite.cc testper.cc) diff --git a/src/madness/chem/QCCalculationParametersBase.cc b/src/madness/mra/QCCalculationParametersBase.cc similarity index 98% rename from src/madness/chem/QCCalculationParametersBase.cc rename to src/madness/mra/QCCalculationParametersBase.cc index 7b0ec8e1932..518ce64c936 100644 --- a/src/madness/chem/QCCalculationParametersBase.cc +++ b/src/madness/mra/QCCalculationParametersBase.cc @@ -5,11 +5,11 @@ * Author: fbischoff */ -#include +#include"QCCalculationParametersBase.h" #include #include #include -#include +#include"worldgop.h" diff --git a/src/madness/chem/QCCalculationParametersBase.h b/src/madness/mra/QCCalculationParametersBase.h similarity index 99% rename from src/madness/chem/QCCalculationParametersBase.h rename to src/madness/mra/QCCalculationParametersBase.h index 91d6add790a..dbdaeccc41c 100644 --- a/src/madness/chem/QCCalculationParametersBase.h +++ b/src/madness/mra/QCCalculationParametersBase.h @@ -15,11 +15,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include "madness/misc/misc.h" +#include "archive.h" +#include "world.h" +#include"commandlineparser.h" +#include"madness/external/nlohmann_json/json.hpp" namespace madness { diff --git a/src/madness/chem/commandlineparser.h b/src/madness/mra/commandlineparser.h similarity index 100% rename from src/madness/chem/commandlineparser.h rename to src/madness/mra/commandlineparser.h diff --git a/src/madness/mra/funcplot.h b/src/madness/mra/funcplot.h index 283e7f1fc47..a48917cf8bc 100644 --- a/src/madness/mra/funcplot.h +++ b/src/madness/mra/funcplot.h @@ -33,7 +33,7 @@ #define MADNESS_MRA_FUNCPLOT_H__INCLUDED #include - +#include "QCCalculationParametersBase.h" /*! \file mra/funcplot.h @@ -44,6 +44,53 @@ */ namespace madness { + + struct PlotParameters : public QCCalculationParametersBase { + PlotParameters(World& world, const commandlineparser parser=commandlineparser(), const std::string tag="plot") : PlotParameters() { + read_input_and_commandline_options(world,parser,tag); + } + + PlotParameters() : QCCalculationParametersBase() { + + // initialize with: key, value, comment (optional), allowed values (optional) + initialize("zoom",2,"zoom into the simulation cell"); + initialize("npoints",151,"number of plot points per dimension"); + initialize>("origin",{0.0,0.0,0.0},"origin of the plot"); + initialize>("plane",{"x1","x2"},"plot plane: x1, x2, .., x6"); + } + + PlotParameters& set_zoom(const double z) { + set_user_defined_value("zoom",z); + return *this; + } + PlotParameters& set_npoints(const long n) { + set_user_defined_value("npoints",n); + return *this; + } + PlotParameters& set_plane(const std::vector plane) { + set_user_defined_value("plane",plane); + return *this; + } + PlotParameters& set_origin(const std::vector origin) { + set_user_defined_value("origin",origin); + return *this; + } + + + double zoom() const {return get("zoom");} + long npoints() const {return get("npoints");} + + template + Vector origin() const { + auto origin_vec=get>("origin"); + Vector o(origin_vec); + return o; + } + + std::vector plane() const {return get>("plane");} + + + }; /// Writes an OpenDX format file with a cube/slice of points on a uniform grid /// Collective operation but only process 0 writes the file. By convention OpenDX @@ -717,65 +764,118 @@ namespace madness { // function.get_impl()->print_plane(filename.c_str(),cc1,cc2,coord); } + +/// plot a 2-d slice of a given function and the according MRA structure + +/// the plotting parameters are taken from the input file "input" and its +/// data group "plot", e.g. plotting the xy plane around (0,0,0.7): +/// plot +/// plane x1 x2 +/// zoom 2.0 +/// npoints 100 +/// origin 0.0 0.0 0.7 +/// end +/// @param[in] world the world +/// @param[in] vfunction the function to plot +/// @param[in] name the output name +template +void plot_plane(World& world, const std::vector >& vfunction, + const std::string name, const PlotParameters param) { + + if (world.size()>1) return; + + auto plane=param.plane(); + std::string c1=plane[0]; + std::string c2=plane[1]; + auto npoints=param.npoints(); + auto origin=param.origin(); + auto coord=param.origin(); + double scale=1.0/param.zoom(); + std::string output_type="gnuplot"; + + auto plane2dim = [](std::string c) { + if (c=="x1") return 0; + else if (c=="x2") return 1; + else if (c=="x3") return 2; + else if (c=="x4") return 3; + else if (c=="x5") return 4; + else if (c=="x6") return 5; + else return -1; + }; + + // convert human to mad form + std::size_t cc1=plane2dim(c1); + std::size_t cc2=plane2dim(c2); + + MADNESS_ASSERT(cc1>=0 && cc1=0 && cc2::get_cell_width()[0]*0.5; + lo=lo*scale; + + const double stepsize=FunctionDefaults::get_cell_width()[0]*scale/npoints; + + if(world.rank() == 0) { + + // plot 3d plot + FILE *f = 0; + f=fopen(filename.c_str(), "w"); + if(!f) MADNESS_EXCEPTION("plot_along: failed to open the plot file", 0); + + for (int i0=0; i0 - void plot_plane(World& world, const opT& op, const std::string name) { + void plot_plane(World& world, const opT& op, const std::string name, const PlotParameters param) { if (world.size()>1) return; - // determine the ploting plane - std::string c1, c2; - - // zoom factor - double zoom=1.0; - - // output type: mathematica or gnuplot - std::string output_type="gnuplot"; - - // number of points in each direction - int npoints=200; - - // the coordinates to be plotted - Vector coord(0.0); - Vector origin(0.0); - - try { - std::ifstream f("input"); - position_stream(f, "plot"); - std::string s; - while (f >> s) { - if (s == "end") { - break; - } else if (s == "plane") { - f >> c1 >> c2; - } else if (s == "zoom") { - f >> zoom; - } else if (s == "output") { - f >> output_type; - } else if (s == "points") { - f >> npoints; - } else if (s == "origin") { - for (std::size_t i=0; i> origin[i]; - } - } - } catch (...) { - print("can't locate plot in file input -- using default values"); - } - double scale=1.0/zoom; - coord=origin; - - // convert human to mad form - int cc1=0, cc2=1; - if (c1=="x1") cc1=0; - if (c1=="x2") cc1=1; - if (c1=="x3") cc1=2; - if (c1=="x4") cc1=3; - if (c1=="x5") cc1=4; - if (c1=="x6") cc1=5; - if (c2=="x1") cc2=0; - if (c2=="x2") cc2=1; - if (c2=="x3") cc2=2; - if (c2=="x4") cc2=3; - if (c2=="x5") cc2=4; - if (c2=="x6") cc2=5; + + auto plane=param.plane(); + std::string c1=plane[0]; + std::string c2=plane[1]; + auto npoints=param.npoints(); + auto origin=param. template origin(); + auto coord=param. template origin(); + double scale=1.0/param.zoom(); + std::string output_type="gnuplot"; + + auto plane2dim = [](std::string c) { + if (c=="x1") return 0; + else if (c=="x2") return 1; + else if (c=="x3") return 2; + else if (c=="x4") return 3; + else if (c=="x5") return 4; + else if (c=="x6") return 5; + else return -1; + }; + + // convert human to mad form + std::size_t cc1=plane2dim(c1); + std::size_t cc2=plane2dim(c2); + + MADNESS_ASSERT(cc1>=0 && cc1=0 && cc2 -#include -#include +#include"QCCalculationParametersBase.h" +#include"parallel_archive.h" using namespace madness; @@ -443,7 +442,7 @@ bool test_derived(World& world) { int main(int argc, char** argv) { initialize(argc, argv); World world(SafeMPI::COMM_WORLD); - startup(world,argc,argv); +// startup(world,argc,argv); std::cout.precision(6); int success=0;