50 print(
'Would you like to use default values for the {:} grid? - Yes (y) or No (n)'.format(param))
51 print(
'Default: min={:}, max={:}, num={:}'.format(default[0],default[1],default[2]))
52 use_def = input(
'Your response ("y" or "n"): ')
54 while not (use_def
in options):
56 print(
'Error: Invalid response, please enter "y" or "n", without quotes.')
57 use_def = input(
'Your response: ')
75 print(
'Default: ',tag,
'=',defaults[idx])
76 step = input(
'Your response: ')
80 elif not(
isint(step)):
82 print(
'Error: Invalid response. The program is expecting a positive integer, or blank for default.')
83 print(
'Please have another go.')
90 print(
'Error: Invalid response. The program is expecting an positive integer, or blank for default.')
91 print(
'Please have another go.')
111 print(
'Default: ',tag,
'=',defaults)
113 print(
'Default: ',tag,
'=',defaults[idx])
114 pf = input(
'Your response: ')
120 print(
'Error: Invalid response. The program is expecting a positive float, or blank for default.')
121 print(
'Please have another go.')
128 print(
'Error: Invalid response. The program is expecting an positive float, or blank for default.')
129 print(
'Please have another go.')
144 mini = input(
'Enter minimum value for {:} grid: '.format(param))
147 print(
'Error: Invalid response. The program is expecting a float.')
148 mini = input(
'Enter minimum value for {:} grid: '.format(param))
154 maxi = input(
'Enter maximum value for {:} grid: '.format(param))
157 print(
'Error: Invalid response. The program is expecting a float.')
158 maxi = input(
'Enter maximum value for {:} grid: '.format(param))
162 print(
'Error: Invalid response. Choose a maximum value that is larger than your chosen minimum={:}.'.format(mini))
167 num = input(
'Enter integer number of grid points (inclusive of max & min): ')
168 while not(
isint(num)):
170 print(
'Error: Invalid response. The program is expecting a positive integer.')
171 num = input(
'Enter integer number of grid points (inclusive of max & min): ')
175 print(
'Error: Invalid response. The program is expecting a positive integer.')
178 return str(mini), str(maxi), str(num)
192 control, params = {}, {}
196 print(
'Which system would you like to solve?')
197 print(
'a) Quantum Harmonic Oscillator')
198 print(
'b) Hydrogen Molecule Ion H2+')
199 print(
'c) Hydrogen Molecule H2')
200 print(
'd) Run Test Cases')
201 sys = input(
'Your response ("a", "b", "c" or "d"): ')
203 options = [
'a',
'b',
'c',
'd']
204 while not (sys
in options):
206 print(
'Error: Invalid response, please enter "a", "b", "c" or "d", without quotes.')
207 sys = input(
'Your response: ')
209 settings = [
"'QHO'",
"'H2plus'",
"'H2'",
"'test'"]
210 messages = [
'Quantum Harmonic Oscillator',
'Hydrogen Molecule Ion',
'Hydrogen Molecule',
'Test Cases']
211 sys_idx = options.index(sys)
212 control[
'p_system'] = settings[sys_idx]
214 print(
'You have chosen the ' + messages[options.index(sys)] +
'.')
219 return control,
'test'
223 print(
'What type of calculation would you like to perform?')
224 print(
'a) Equilibration run, to determine burning & thinning step sizes')
225 print(
'b) VQMC calculation')
226 calc = input(
'Your response ("a" or "b"): ')
229 while not (calc
in options):
230 print(
'Error: Invalid response, please enter "a" or "b", without quotes.')
231 calc = input(
'Your response: ')
233 settings = [
'.TRUE.',
'.FALSE.']
234 messages = [
'an Equilibration run.',
'a VQMC calculation.',]
235 control[
'run_equil'] = settings[options.index(calc)]
237 print(
'You have chosen to do ' + messages[options.index(calc)])
240 control[
'run_restart'] =
'.FALSE.'
244 print(
'Would you like the program to write restart files? - Yes (y) or No (n)')
245 w_res = input(
'Your response ("y" or "n"): ')
248 while not (w_res
in options):
250 print(
'Error: Invalid response, please enter "y" or "n", without quotes.')
251 w_res = input(
'Your response: ')
253 settings = [
'.TRUE.',
'.FALSE.']
254 messages = [
'to',
'not to',]
255 control[
'write_restart'] = settings[options.index(w_res)]
257 print(
'You have requested the program {:} write restart files.'. format(messages[options.index(w_res)]))
262 print(
'By default, restart files will be written after the MMC loop of every grid point in the parameter optimization.')
263 print(
'If you want the restart files to be written less frequently, enter the required interval of grid points.')
264 print(
'Else, for the default behaviour, leave a blank response below (ie., press \'Enter\').')
265 prompt=
'Enter interval of points in grid-search for writing restart files.'
267 steps =
query_step(prompt, tag, d_rnum, sys_idx)
271 control[tag] = str(steps)
277 print(
'Would you like the program to save the Markov chains (after burning & thinning)?')
278 print(
'y) Yes, I would like a detailed output for wavefunction visualization.')
279 print(
'n) No, just give me the final energies and optimized parameters.')
280 temp = input(
'Your response ("y" or "n"): ')
283 while not (temp
in options):
285 print(
'Error: Invalid response, please enter "y" or "n", without quotes.')
286 temp = input(
'Your response: ')
288 settings = [
'.TRUE.',
'.FALSE.']
289 messages = [
'output',
'not output']
290 control[
'write_chains'] = settings[options.index(temp)]
292 print(
'Your have requested the program to {:} the Markov chains.'.format(messages[options.index(temp)]))
296 print(
'Would you like the program to write a logfile? - Yes (y) or No (n)')
297 temp = input(
'Your response ("y" or "n"): ')
300 while not (temp
in options):
302 print(
'Error: Invalid response, please enter "y" or "n", without quotes.')
303 temp = input(
'Your response: ')
305 settings = [
'.TRUE.',
'.FALSE.']
306 messages = [
'to',
'not to',]
307 control[
'write_log'] = settings[options.index(temp)]
309 print(
'You have requested the program {:} write a logfile.'. format(messages[options.index(temp)]))
315 print(
'If you wish to use defaults for any prompt that follows, leave a blank response for it (ie., press \'Enter\').')
321 prompt =
'Enter total number of MMC steps.'
323 d_steps=d_equi_steps.copy()
325 d_steps=d_vqmc_steps.copy()
326 steps =
query_step(prompt,tag,d_steps,sys_idx)
328 steps = d_steps[sys_idx]
330 params[tag] = str(steps)
339 prompt =
'Enter an integer step-size for burning.'
341 while not(b_step<steps
or b_step==
''):
342 b_step =
query_step(prompt,tag,d_bstep,sys_idx)
344 b_step = d_bstep[sys_idx]
346 params[tag] = str(b_step)
349 print(
'Error: Invalid response. The program is expecting burn_step < {:} as you chose steps={:}.'.format(steps,steps))
350 print (
'Please have another go.')
354 prompt =
'Enter an integer step-size for thinning.'
355 t_max = steps - b_step
357 while not(t_step<t_max
or t_step==
''):
358 t_step =
query_step(prompt,tag,d_tstep,sys_idx)
360 t_step = d_tstep[sys_idx]
362 params[tag] = str(t_step)
365 print(
'Error: Invalid response. The program is expecting thin_step < {:} as you chose steps-burn_steps={:}.'.format(t_max,t_max))
366 print (
'Please have another go.')
371 prompt=
'Enter cutoff radial distance (in Bohr) for MMC search.'
374 params[tag] = str(temp)
379 prompt=
'Enter sigma, the standard deviation of the Gaussian used to propose MMC steps.'
382 params[tag] = str(temp)
392 print(
'Quantity of interest "alpha" is the factor in the exponent of the Quantum Harmonic Oscillator system.')
402 params[tag] =
'{:}, {:}, {:}'.format(mini, maxi, num)
411 print(
'Which method would you like to use for parameter optimization at each bondlength?')
412 print(
'a) Automatic search by conjugate-gradient method, starting from a trial value for c.')
413 print(
'b) Grid search, over an input grid of trial values for c')
414 auto = input(
'Your response ("a" or "b"): ')
417 while not (auto
in options):
418 print(
'Error: Invalid response, please enter "a" or "b", without quotes.')
419 auto = input(
'Your response: ')
421 settings = [
'.TRUE.',
'.FALSE.']
422 params[tag] = settings[options.index(auto)]
433 print(
'Parameter "c" is a coefficient in the Hydrogen Ion wavefunction.')
447 prompt=
'Enter starting guess value for the conjugate-gradient search of parameter c.'
450 params[tag] = str(temp)
461 params[tag] =
'{:}, {:}, {:}'.format(mini, maxi, num)
466 print(
'Quantity of interest "bond" is the Hydrogen bondlength in Bohr units.')
476 params[tag] =
'{:}, {:}, {:}'.format(mini, maxi, num)
484 print(
'Which method would you like to use for parameter optimization at each bondlength?')
485 print(
'a) Automatic search by conjugate-gradient method, starting from a trial value for beta.')
486 print(
'b) Grid search, over an input grid of trial values for beta')
487 auto = input(
'Your response ("a" or "b"): ')
490 while not (auto
in options):
491 print(
'Error: Invalid response, please enter "a" or "b", without quotes.')
492 auto = input(
'Your response: ')
494 settings = [
'.TRUE.',
'.FALSE.']
495 params[tag] = settings[options.index(auto)]
499 print(
'Parameter "beta" is a coefficient in the Hydrogen Molecule wavefunction.')
506 prompt=
'Enter starting guess value for the conjugate-gradient search of parameter beta.'
509 params[tag] = str(temp)
520 params[tag] =
'{:}, {:}, {:}'.format(mini, maxi, num)
525 print(
'Quantity of interest "bond" is the Hydrogen bondlength in Bohr units.')
535 params[tag] =
'{:}, {:}, {:}'.format(mini, maxi, num)
539 return control, params
550 f = open(
'params.txt',
'w')
553 f.write(
'&CONTROL\n')
554 for tag
in control.keys():
555 f.write(tag+
' \t= '+str(control[tag])+
'\n')
560 f.write(
'&PARAMETERS\n')
563 f.write(
'&PARAMETERS\n')
564 sys = control[
'p_system'].replace(
"'",
"")
566 for tag
in params.keys():
567 f.write(sys+
'%'+tag+
' \t= '+params[tag]+
'\n')
Contains default values for input parameters of Dice QMC.
def isfloat(s)
Checks if the input string represents a float.
def query_grid(param)
Queries user for the minimum, maximum and number of points of a parameter grid.
def query_default(param, default)
Queries whether the user wants to use default values for a certain parameter.
def query_posfloat(prompt, tag, defaults, idx=None)
Queries a positive float value, using the input string as a prompt.
def query_step(prompt, tag, defaults, idx)
Queries an integer step value, using the input string as a prompt.
def isint(s)
Checks if the input string represents an integer.
def write_params(control, params)
Major subroutine that writes the input file params.txt.
def query_params()
Major function that queries the user for all the inputs required to assemble params....