Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/coupled-basis-scan'
Browse files Browse the repository at this point in the history
  • Loading branch information
pprvatto committed Oct 2, 2020
2 parents 506acc3 + 8fbee55 commit faca36a
Show file tree
Hide file tree
Showing 3 changed files with 278 additions and 55 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,31 @@ Keyword | Description | Number of parameters | Type | Default value
`QAG-KEY-COUPLED` | GSL key for selecting the QAG integrator order for the rotor chain | 1 | `int` | 6
`SAVE-VQE` | Setting the flag to `1` or `0` activate or deactivate the generation of a file containing the matrix of sFPS operator integrals on the composite basis set | 1 | `bool` (as `0` or `1`) | 0
`SAVE-EIGVAL-LIST` | Setting the flag to `1` or `0` activate or deactivate the generation of a file containing all the eigenvalues computed for the system | 1 | `bool` (as `0` or `1`) | 0
`SINGLE-COUPLED_SCAN` | Setup a basis-set dimension scan for a defined dihedral (for more informations see the "Independent coupled basis scan keyword" section) | 4 | `integer list` | -
`LOCKED-COUPLED_SCAN` | Setup a basis-set dimension scan for all dihedral (for more informations see the "Locked coupled basis scan keyword" section) | 3 | `integer list` | -

### Independent coupled basis scan keyword
The `SINGLE-COUPLED-SCAN` keyword can be used to set up a scan on the number of basis functions for each dihedral angle. The function varies the basis set cutoff for the selected dihedral and overrides the corresponent`SINGLE-COUPLED-BASIS` instruction. The following four `integer` syntax can be used:
```
# SINGLE-COUPLED-SCAN
<dihedral number>, <initial basis set>, <final basis set>, <step>
```
For example the instruction:
```
# SINGLE-COUPLED-SCAN
0, 4, 7, 1
```
will run a calculation for `4`, `5`, `6`, `7` basis functions for the first rotor of the chain while keeping the number of basis function constant for the remaining rotors. Multiple scan instructions are not implemented at the moment, subsequent calls to `SINGLE-COUPLED-SCAN` will override all previous instructions except the last one. If the user want to scan all dihedral simultaneousy the keyword `LOCKED-COUPLED-SCAN` must be used (see next section for more details).

### Locked coupled basis scan keyword
The `LOCKED-COUPLED-SCAN` keyword can be used to set up a scan on the number of basis functions for all the dihedral angles in the chain. The function varies the basis set cutoff for all the dihedrals and overrides the corresponent`COUPLED-BASIS` instruction. The following three `integer` syntax can be used:
```
# LOCKED-COUPLED-SCAN
<initial basis set>, <final basis set>, <step>
```
For example the instruction:
```
# LOCKED-COUPLED-SCAN
4, 7, 1
```
will run a calculation setting the cutoff for all dihedral basis to `4`, `5`, `6`, `7`.
70 changes: 64 additions & 6 deletions ioparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace input{

const int NUM_COMM = 16; //Total number of available commands
const int NUM_COMM = 18; //Total number of available commands
std::string COMMAND_LIST[NUM_COMM] ={ //Commands list
"NROT",
"NUM-MIN",
Expand All @@ -35,7 +35,9 @@ namespace input{
"REL-INTEG-COUPLED",
"QAG-KEY-COUPLED",
"SAVE-VQE",
"SAVE-EIGVAL-LIST"
"SAVE-EIGVAL-LIST",
"SINGLE-COUPLED-SCAN",
"LOCKED-COUPLED-SCAN"
};

template <class T>
Expand All @@ -62,10 +64,10 @@ namespace input{
class INPUT_PARSER{
private:
std::string filename;
bool init_flag, load_flag, vqe_key, eigval_list_key;
bool init_flag, load_flag, vqe_key, eigval_list_key, scan_flag, locked_scan_flag;
int num_rot, num_dihed, npt_int_single, npt_int_coupled, key_single, key_coupled;
double abs_single, rel_single, abs_coupled, rel_coupled;
int *basis_single, *basis_coupled, *num_mins;
int *basis_single, *basis_coupled, *num_mins, *scan_settings, *locked_scan_settings;
double *diffusion, *barrier;

protected:
Expand Down Expand Up @@ -157,6 +159,8 @@ namespace input{
exit(EXIT_FAILURE);
}
init_flag = true;
scan_flag = false;
locked_scan_flag = false;
}

~INPUT_PARSER(){
Expand All @@ -167,6 +171,12 @@ namespace input{
delete[] barrier;
delete[] diffusion;
}
if(scan_flag==true){
delete[] scan_settings;
}
if(locked_scan_flag==true){
delete[] locked_scan_settings;
}
}

int load(){
Expand Down Expand Up @@ -225,13 +235,39 @@ namespace input{
case 15:
std::stringstream(line) >> eigval_list_key;
break;
case 16:
scan_flag = true;
scan_settings = new int[4];
read_list_line<int>(line, ",", scan_settings, 4);
if(scan_settings[3]==0){
std::cout << "WARNING (input-parser): The scan step cannot be zero" << std::endl;
std::cout << " -> Setting the step to 1" << std::endl;
scan_settings[3] = 1;
}
break;
case 17:
locked_scan_flag = true;
locked_scan_settings = new int[3];
read_list_line<int>(line, ",", locked_scan_settings, 3);
if(locked_scan_settings[2]==0){
std::cout << "WARNING (input-parser): The scan step cannot be zero" << std::endl;
std::cout << " -> Setting the step to 1" << std::endl;
locked_scan_settings[2] = 1;
}
break;
default:
break;
}
}
}
input.close();
load_flag = true;
if(scan_flag==true && locked_scan_flag==true){
std::cout << "WARNING (input-parser): Conflicting scan instructions were given in the input file" << std::endl;
std::cout << " -> Only the locked scan will be performed" << std::endl;
delete[] scan_settings;
scan_flag = false;
}
return num_rot;
}

Expand Down Expand Up @@ -262,12 +298,34 @@ namespace input{
}
}

void get_general_settings(bool& vqe_key_, bool& eigval_list_key_){
void get_general_settings(bool& vqe_key_, bool& eigval_list_key_, bool& scan_flag_, bool& locked_scan_flag_){
vqe_key_ = vqe_key;
eigval_list_key_ = eigval_list_key;
scan_flag_ = scan_flag;
locked_scan_flag_ = locked_scan_flag;
}

void coupled_scan_settings(int& dihedral_, int& start_, int& final_, int& step_){
if(scan_flag==false){
std::cout << "ERROR (input-parser): Single dihedral scan has not been set" << std::endl;
exit(EXIT_FAILURE);
}
dihedral_ = scan_settings[0];
start_ = scan_settings[1];
final_ = scan_settings[2];
step_ = scan_settings[3];
}
};

void coupled_locked_scan_settings(int& start_, int& final_, int& step_){
if(locked_scan_flag==false){
std::cout << "ERROR (input-parser): Locked multiple dihedral scan has not been set" << std::endl;
exit(EXIT_FAILURE);
}
start_ = locked_scan_settings[0];
final_ = locked_scan_settings[1];
step_ = locked_scan_settings[2];
}
};
}

namespace output{
Expand Down
Loading

0 comments on commit faca36a

Please sign in to comment.