Skip to content
Open
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
4 changes: 2 additions & 2 deletions source/source_pw/module_ofdft/ml_tools/input.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./input.h"

#include <string>
void Input::readInput()
{
std::ifstream ifs("nnINPUT", std::ios::in);
Expand All @@ -9,7 +9,7 @@ void Input::readInput()
exit(0);
}

char word[80];
std::string word;
int ierr = 0;

ifs.rdstate();
Expand Down
10 changes: 6 additions & 4 deletions source/source_pw/module_stodft/sto_wf.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sto_wf.h"

#include <random>
#include "source_base/memory.h"
#include "source_io/module_parameter/parameter.h"

Expand Down Expand Up @@ -136,19 +136,21 @@ void Stochastic_WF<T, Device>::update_sto_orbitals(const int seed_in)
{
const int nchi = PARAM.inp.nbands_sto;
this->chi0_cpu->fix_k(0);
static std::mt19937 gen(std::random_device{}());
std::uniform_real_distribution<double> dist(0.0, 1.0);
if (seed_in >= 0)
{
for (int i = 0; i < this->chi0_cpu->size(); ++i)
{
const double phi = 2 * ModuleBase::PI * rand() / double(RAND_MAX);
{
const double phi = 2 * ModuleBase::PI * dist(gen);
this->chi0_cpu->get_pointer()[i] = std::complex<double>(cos(phi), sin(phi)) / sqrt(double(nchi));
}
}
else
{
for (int i = 0; i < this->chi0_cpu->size(); ++i)
{
if (rand() / double(RAND_MAX) < 0.5)
if (dist(gen) < 0.5)
{
this->chi0_cpu->get_pointer()[i] = -1.0 / sqrt(double(nchi));
}
Expand Down