Skip to content

Commit faca36a

Browse files
author
pprvatto
committed
Merge remote-tracking branch 'origin/coupled-basis-scan'
2 parents 506acc3 + 8fbee55 commit faca36a

3 files changed

Lines changed: 278 additions & 55 deletions

File tree

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,31 @@ Keyword | Description | Number of parameters | Type | Default value
7272
`QAG-KEY-COUPLED` | GSL key for selecting the QAG integrator order for the rotor chain | 1 | `int` | 6
7373
`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
7474
`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
75+
`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` | -
76+
`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` | -
77+
78+
### Independent coupled basis scan keyword
79+
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:
80+
```
81+
# SINGLE-COUPLED-SCAN
82+
<dihedral number>, <initial basis set>, <final basis set>, <step>
83+
```
84+
For example the instruction:
85+
```
86+
# SINGLE-COUPLED-SCAN
87+
0, 4, 7, 1
88+
```
89+
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).
90+
91+
### Locked coupled basis scan keyword
92+
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:
93+
```
94+
# LOCKED-COUPLED-SCAN
95+
<initial basis set>, <final basis set>, <step>
96+
```
97+
For example the instruction:
98+
```
99+
# LOCKED-COUPLED-SCAN
100+
4, 7, 1
101+
```
102+
will run a calculation setting the cutoff for all dihedral basis to `4`, `5`, `6`, `7`.

ioparser.h

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace input{
2020

21-
const int NUM_COMM = 16; //Total number of available commands
21+
const int NUM_COMM = 18; //Total number of available commands
2222
std::string COMMAND_LIST[NUM_COMM] ={ //Commands list
2323
"NROT",
2424
"NUM-MIN",
@@ -35,7 +35,9 @@ namespace input{
3535
"REL-INTEG-COUPLED",
3636
"QAG-KEY-COUPLED",
3737
"SAVE-VQE",
38-
"SAVE-EIGVAL-LIST"
38+
"SAVE-EIGVAL-LIST",
39+
"SINGLE-COUPLED-SCAN",
40+
"LOCKED-COUPLED-SCAN"
3941
};
4042

4143
template <class T>
@@ -62,10 +64,10 @@ namespace input{
6264
class INPUT_PARSER{
6365
private:
6466
std::string filename;
65-
bool init_flag, load_flag, vqe_key, eigval_list_key;
67+
bool init_flag, load_flag, vqe_key, eigval_list_key, scan_flag, locked_scan_flag;
6668
int num_rot, num_dihed, npt_int_single, npt_int_coupled, key_single, key_coupled;
6769
double abs_single, rel_single, abs_coupled, rel_coupled;
68-
int *basis_single, *basis_coupled, *num_mins;
70+
int *basis_single, *basis_coupled, *num_mins, *scan_settings, *locked_scan_settings;
6971
double *diffusion, *barrier;
7072

7173
protected:
@@ -157,6 +159,8 @@ namespace input{
157159
exit(EXIT_FAILURE);
158160
}
159161
init_flag = true;
162+
scan_flag = false;
163+
locked_scan_flag = false;
160164
}
161165

162166
~INPUT_PARSER(){
@@ -167,6 +171,12 @@ namespace input{
167171
delete[] barrier;
168172
delete[] diffusion;
169173
}
174+
if(scan_flag==true){
175+
delete[] scan_settings;
176+
}
177+
if(locked_scan_flag==true){
178+
delete[] locked_scan_settings;
179+
}
170180
}
171181

172182
int load(){
@@ -225,13 +235,39 @@ namespace input{
225235
case 15:
226236
std::stringstream(line) >> eigval_list_key;
227237
break;
238+
case 16:
239+
scan_flag = true;
240+
scan_settings = new int[4];
241+
read_list_line<int>(line, ",", scan_settings, 4);
242+
if(scan_settings[3]==0){
243+
std::cout << "WARNING (input-parser): The scan step cannot be zero" << std::endl;
244+
std::cout << " -> Setting the step to 1" << std::endl;
245+
scan_settings[3] = 1;
246+
}
247+
break;
248+
case 17:
249+
locked_scan_flag = true;
250+
locked_scan_settings = new int[3];
251+
read_list_line<int>(line, ",", locked_scan_settings, 3);
252+
if(locked_scan_settings[2]==0){
253+
std::cout << "WARNING (input-parser): The scan step cannot be zero" << std::endl;
254+
std::cout << " -> Setting the step to 1" << std::endl;
255+
locked_scan_settings[2] = 1;
256+
}
257+
break;
228258
default:
229259
break;
230260
}
231261
}
232262
}
233263
input.close();
234264
load_flag = true;
265+
if(scan_flag==true && locked_scan_flag==true){
266+
std::cout << "WARNING (input-parser): Conflicting scan instructions were given in the input file" << std::endl;
267+
std::cout << " -> Only the locked scan will be performed" << std::endl;
268+
delete[] scan_settings;
269+
scan_flag = false;
270+
}
235271
return num_rot;
236272
}
237273

@@ -262,12 +298,34 @@ namespace input{
262298
}
263299
}
264300

265-
void get_general_settings(bool& vqe_key_, bool& eigval_list_key_){
301+
void get_general_settings(bool& vqe_key_, bool& eigval_list_key_, bool& scan_flag_, bool& locked_scan_flag_){
266302
vqe_key_ = vqe_key;
267303
eigval_list_key_ = eigval_list_key;
304+
scan_flag_ = scan_flag;
305+
locked_scan_flag_ = locked_scan_flag;
306+
}
307+
308+
void coupled_scan_settings(int& dihedral_, int& start_, int& final_, int& step_){
309+
if(scan_flag==false){
310+
std::cout << "ERROR (input-parser): Single dihedral scan has not been set" << std::endl;
311+
exit(EXIT_FAILURE);
312+
}
313+
dihedral_ = scan_settings[0];
314+
start_ = scan_settings[1];
315+
final_ = scan_settings[2];
316+
step_ = scan_settings[3];
268317
}
269-
};
270318

319+
void coupled_locked_scan_settings(int& start_, int& final_, int& step_){
320+
if(locked_scan_flag==false){
321+
std::cout << "ERROR (input-parser): Locked multiple dihedral scan has not been set" << std::endl;
322+
exit(EXIT_FAILURE);
323+
}
324+
start_ = locked_scan_settings[0];
325+
final_ = locked_scan_settings[1];
326+
step_ = locked_scan_settings[2];
327+
}
328+
};
271329
}
272330

273331
namespace output{

0 commit comments

Comments
 (0)