Running iDEA¶
As it is a python package there are many different ways of running iDEA.
Using the iDEA code directly¶
Use idea-run to produce the default parameters file:
idea-run
In order not to overwrite results from different calculations, make sure to choose different run names for different inputs
### Library imports
from __future__ import division
from iDEA.input import InputSection, SystemSection
import numpy as np
### Run parameters
run = InputSection()
run.name = 'run_name' #: Name to identify run. Note: Do not use spaces or any special characters (.~[]{}<>?/\)
run.time_dependence = False #: Run time-dependent calculation
run.verbosity = 'default' #: Output verbosity ('low', 'default', 'high')
run.save = True #: Save results to disk when they are generated
run.module = 'iDEA' #: Specify alternative folder (in this directory) containing modified iDEA module
run.NON = True #: Run Non-Interacting approximation
run.LDA = False #: Run LDA approximation
run.HF = False #: Run Hartree-Fock approximation
run.HYB = False #: Run Hybrid (HF-LDA) calculation
run.EXT = True #: Run Exact Many-Body calculation
Using the iDEA package in a python script¶
Since iDEA is designed as a python package, it can be run from everywhere, if you let your python installation know where the package is located. During the installation of iDEA the idea-public directory should have been added to PYTHONPATH. To test this has worked simply perform the following
cd $test_folder # some folder you have created
cp $path_to_iDEA/iDEA/parameters.py . # where you have downloaded iDEA
idea-run
Here, we are running iDEA much in the same way as before but your
$test_folder
can be located anywhere on your computer.
The main advantage of having an iDEA python package is that you can access its functionality directly in a python script.
The example below uses a python loop to converge the grid spacing for an iDEA calculation of a test system of non-interacting electrons in a harmonic well.
from iDEA.input import Input
# read parameters file
inp = Input.from_python_file('parameters.py')
inp.run.verbosity = 'low'
# Converging xmax parameter
for xmax in [4,6,8,10]:
# Note: the dependent sys.deltax is automatically updated
inp.sys.xmax = xmax
# perform checks on input parameters
inp.check()
inp.execute()
E = inp.results.non.gs_non_E
print(" xmax = {:4.1f}, E = {:6.4f} Ha".format(xmax,E))
In order to run this example, save it to a file run.py
and do
python run.py
Using the iDEA package in an ipython shell¶
As iDEA is a python package it can also be run from the interactive python shell
(ipython
). This is particularly useful as ipython has a convenient auto-complete
feature. The following example can be run in an ipython shell line-by-line.
from iDEA.input import Input
# import parameters file
pm = Input.from_python_file('parameters.py')
# change parameters
pm.run.EXT = True
pm.run.NON = True
print(pm.run)
# run jobs
results = pm.execute()
# plot the relevant results
x = pm.space.grid
plt.plot(x, results.ext.gs_ext_den, label='exact')
plt.plot(x, results.non.gs_non_den, label='non-interacting')
plt.legend()
plt.show()