Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release #276

Merged
merged 24 commits into from
Oct 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9080ac2
Reenable testShortSighted test (#248)
jeanlucf22 Jun 4, 2024
f13236f
Make new driver to check input (#247)
jeanlucf22 Jun 4, 2024
bad80d1
Add possible periodic dimensions to xyz2in.py (#249)
jeanlucf22 Jun 4, 2024
7aac379
Remove unused/untested option extrapolateH (#250)
jeanlucf22 Jun 4, 2024
bffc514
Exit with failure if density off by more than 2% (#251)
jeanlucf22 Jun 6, 2024
de1be3b
Example driver (#252)
jeanlucf22 Jun 6, 2024
13b8642
loadOrbitalsFromRestartFile -> loadRestartFile (#253)
dreamer2368 Jun 14, 2024
3eaf5a6
Add SG15 PBE potential for N (#258)
jeanlucf22 Jul 20, 2024
bc897c6
Update 2-pyridone example (#259)
jeanlucf22 Jul 22, 2024
3c11121
Adjust verbosity in some functions (#260)
jeanlucf22 Jul 29, 2024
35ba70f
Add new example: pinned H2O (#261)
jeanlucf22 Jul 29, 2024
bde8506
Print out eigenvalues out of MVP solver (#262)
jeanlucf22 Jul 30, 2024
4bbb64e
Add Li2 example with local GTH potential (#263)
jeanlucf22 Jul 31, 2024
0ead573
Fix LBFGS termination when converged (#264)
jeanlucf22 Jul 31, 2024
b7e75a2
Remove unused code to extrapolate rho (#265)
jeanlucf22 Jul 31, 2024
7bcd787
Fix and test EnergyAndForces interface (#266)
jeanlucf22 Aug 1, 2024
e0ad1a9
Add new functionality to compute energy and forces (#267)
jeanlucf22 Aug 8, 2024
8f03cb6
Add functionality to compute energy and forces (#270)
jeanlucf22 Aug 12, 2024
b62a593
Add ONCV for Sulfur + example (#275)
jeanlucf22 Sep 19, 2024
6a8a1d1
Merge branch 'release' into merge_release
siuwuncheung Sep 22, 2024
da33f94
Fix CMakeList
siuwuncheung Sep 22, 2024
f1d42a3
Fix test
siuwuncheung Sep 22, 2024
f0e2d22
Bypass build error
siuwuncheung Sep 23, 2024
a03c891
Fix merge mistake
siuwuncheung Sep 23, 2024
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
Prev Previous commit
Next Next commit
Example driver (#252)
* add example driver, showing use of MGmol as a force/energy computational engine

* clean up related functions in class Ions
  • Loading branch information
jeanlucf22 authored Jun 6, 2024
commit de1be3b23a3d5ac0f8e19bb64bc71f8b5c48ef3e
8 changes: 5 additions & 3 deletions drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
include_directories( ${CMAKE_SOURCE_DIR}/src )

add_executable(check_input
check_input.cc
)
add_executable(check_input check_input.cc)

add_executable(example1 example1.cc)

target_include_directories(check_input PRIVATE ${Boost_INCLUDE_DIRS})
target_include_directories(example1 PRIVATE ${Boost_INCLUDE_DIRS})

target_link_libraries(check_input mgmol_src)
target_link_libraries(example1 mgmol_src)
167 changes: 167 additions & 0 deletions drivers/example1.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
// Copyright (c) 2017, Lawrence Livermore National Security, LLC and
// UT-Battelle, LLC.
// Produced at the Lawrence Livermore National Laboratory and the Oak Ridge
// National Laboratory.
// LLNL-CODE-743438
// All rights reserved.
// This file is part of MGmol. For details, see https://github.com/llnl/mgmol.
// Please also read this link https://github.com/llnl/mgmol/LICENSE

#include "Control.h"
#include "ExtendedGridOrbitals.h"
#include "LocGridOrbitals.h"
#include "MGmol.h"
#include "MGmol_MPI.h"
#include "MPIdata.h"
#include "mgmol_run.h"

#include <cassert>
#include <iostream>
#include <time.h>
#include <vector>

#include <boost/program_options.hpp>
namespace po = boost::program_options;

int main(int argc, char** argv)
{
int mpirc = MPI_Init(&argc, &argv);
if (mpirc != MPI_SUCCESS)
{
std::cerr << "MPI Initialization failed!!!" << std::endl;
MPI_Abort(MPI_COMM_WORLD, 0);
}

MPI_Comm comm = MPI_COMM_WORLD;

/*
* Initialize general things, like magma, openmp, IO, ...
*/
mgmol_init(comm);

/*
* read runtime parameters
*/
std::string input_filename("");
std::string lrs_filename;
std::string constraints_filename("");

float total_spin = 0.;
bool with_spin = false;

po::variables_map vm;

// read from PE0 only
if (MPIdata::onpe0)
{
read_config(argc, argv, vm, input_filename, lrs_filename,
constraints_filename, total_spin, with_spin);
}

MGmol_MPI::setup(comm, std::cout, with_spin);
MGmol_MPI& mmpi = *(MGmol_MPI::instance());
MPI_Comm global_comm = mmpi.commGlobal();

/*
* Setup control struct with run time parameters
*/
Control::setup(global_comm, with_spin, total_spin);
Control& ct = *(Control::instance());

ct.setOptions(vm);

int ret = ct.checkOptions();
if (ret < 0) return ret;

mmpi.bcastGlobal(input_filename);
mmpi.bcastGlobal(lrs_filename);

// Enter main scope
{
if (MPIdata::onpe0)
{
std::cout << "-------------------------" << std::endl;
std::cout << "Construct MGmol object..." << std::endl;
std::cout << "-------------------------" << std::endl;
}

MGmolInterface* mgmol;
if (ct.isLocMode())
mgmol = new MGmol<LocGridOrbitals>(global_comm, *MPIdata::sout,
input_filename, lrs_filename, constraints_filename);
else
mgmol = new MGmol<ExtendedGridOrbitals>(global_comm, *MPIdata::sout,
input_filename, lrs_filename, constraints_filename);

if (MPIdata::onpe0)
{
std::cout << "-------------------------" << std::endl;
std::cout << "MGmol setup..." << std::endl;
std::cout << "-------------------------" << std::endl;
}
mgmol->setup();

if (MPIdata::onpe0)
{
std::cout << "-------------------------" << std::endl;
std::cout << "Setup done..." << std::endl;
std::cout << "-------------------------" << std::endl;
}

// here we just use the atomic positions read in and used
// to initialize MGmol
std::vector<double> positions;
mgmol->getAtomicPositions(positions);
std::vector<short> anumbers;
mgmol->getAtomicNumbers(anumbers);
if (MPIdata::onpe0)
{
std::cout << "Positions:" << std::endl;
std::vector<short>::iterator ita = anumbers.begin();
for (std::vector<double>::iterator it = positions.begin();
it != positions.end(); it += 3)
{
std::cout << *ita;
for (int i = 0; i < 3; i++)
std::cout << " " << *(it + i);
std::cout << std::endl;
ita++;
}
}

// compute energy and forces using all MPI tasks
// expect positions to be replicated on all MPI tasks
std::vector<double> forces;
mgmol->evaluateEnergyAndForces(positions, anumbers, forces);

// print out results
if (MPIdata::onpe0)
{
std::cout << "Forces:" << std::endl;
for (std::vector<double>::iterator it = forces.begin();
it != forces.end(); it += 3)
{
for (int i = 0; i < 3; i++)
std::cout << " " << *(it + i);
std::cout << std::endl;
}
}

delete mgmol;

} // close main scope

mgmol_finalize();

mpirc = MPI_Finalize();
if (mpirc != MPI_SUCCESS)
{
std::cerr << "MPI Finalize failed!!!" << std::endl;
}

time_t tt;
time(&tt);
if (onpe0) std::cout << " Run ended at " << ctime(&tt) << std::endl;

return 0;
}
Loading