Skip to content

Commit

Permalink
Implement the real-time propagation-time command.
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierandrade committed Nov 16, 2024
1 parent 8d71d8e commit b83eaa3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/interface/aliases.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ auto aliases() {
{ "nonlocal"s, "non-local"s },
{ "observable"s, "observables"s },
{ "perturbation"s, "perturbations"s },
{ "propagationtime"s, "propagation-time"s },
{ "pseudo-potential"s, "pseudo"s },
{ "pseudopotential"s, "pseudo"s },
{ "pseudoset"s, "pseudo-set"s },
Expand Down
36 changes: 35 additions & 1 deletion src/interface/real_time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ simulations. These are the available options:
Python example: `pinq.real_time.num-steps(10000)`
- Shell: `real-time propagation-time <value> <units>`
Python: `real_time.propagation_time(value, units)`
Sets the number of step so that the total propagation time is
(slightly larger than) `value`. You need to pass the units as a
second argument, you can use "atu" (or "atomictimeunits"), "as" or
"fs" among others.
Note that this variable directly calculates the number of steps
based on the currently defined time-step. If the time-step is later
changed the number of steps will remain unchanged and the
propagation time will change.
Shell example: `inq real-time propagation-time 10.0 fs`
Python example: `pinq.real_time.propagation_time(10.0, "fs")`
- Shell: `real-time ions <value>`
Python: `real_time.ions.static()`
`real_time.ions.impulsive()`
Expand Down Expand Up @@ -142,6 +159,13 @@ simulations. These are the available options:
opts.save(input::environment::global().comm(), ".inq/default_real_time_options");
}

static void propagation_time(quantity<magnitude::time> pt) {
using namespace magnitude;

auto opts = options::real_time::load(".inq/default_real_time_options").propagation_time(pt);
opts.save(input::environment::global().comm(), ".inq/default_real_time_options");
}

static void ions_static() {
auto opts = options::real_time::load(".inq/default_real_time_options").static_ions();
opts.save(input::environment::global().comm(), ".inq/default_real_time_options");
Expand Down Expand Up @@ -186,7 +210,13 @@ simulations. These are the available options:
if(not quiet) operator()();
actions::normal_exit();
}


if(args.size() == 3 and (args[0] == "propagation-time")){
propagation_time(magnitude::time::parse(str_to<double>(args[1]), args[2]));
if(not quiet) operator()();
actions::normal_exit();
}

if(args.size() == 2 and (args[0] == "num-steps")){
num_steps(str_to<long>(args[1]));
if(not quiet) operator()();
Expand Down Expand Up @@ -257,6 +287,10 @@ simulations. These are the available options:
sub.def("time_step", [](double dt, std::string const & units){
time_step(magnitude::time::parse(dt, units));
}, "dt"_a, "units"_a);

sub.def("propagation_time", [](double time, std::string const & units){
propagation_time(magnitude::time::parse(time, units));
}, "time"_a, "units"_a);

sub.def("num_steps", &num_steps);

Expand Down
10 changes: 8 additions & 2 deletions src/options/real_time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ class real_time {
solver.num_steps_ = etol;
return solver;
}


auto propagation_time(quantity<magnitude::time> pt) const {
real_time solver = *this;;
solver.num_steps_ = ceil(pt.in_atomic_units()/dt());
return solver;
}

auto num_steps() const {
return num_steps_.value_or(100);
}
Expand Down Expand Up @@ -246,7 +252,7 @@ class real_time {
out << "\n";

auto time = self.num_steps()*self.dt();
out << " propagation time = " << time << " atu | " << time/in_atomic_units(1.0_fs) << " fs";
out << " propagation-time = " << time << " atu | " << time/in_atomic_units(1.0_fs) << " fs";
if(not self.num_steps_.has_value()) out << " *";
out << "\n";

Expand Down

0 comments on commit b83eaa3

Please sign in to comment.