~ubuntu-branches/ubuntu/utopic/nwchem/utopic

« back to all changes in this revision

Viewing changes to src/tools/ga-5-1/python/benchmarks/from_distnumpy/jacobi.py

  • Committer: Package Import Robot
  • Author(s): Michael Banck, Daniel Leidert, Andreas Tille, Michael Banck
  • Date: 2013-07-04 12:14:55 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130704121455-5tvsx2qabor3nrui
Tags: 6.3-1
* New upstream release.
* Fixes anisotropic properties (Closes: #696361).
* New features include:
  + Multi-reference coupled cluster (MRCC) approaches
  + Hybrid DFT calculations with short-range HF 
  + New density-functionals including Minnesota (M08, M11) and HSE hybrid
    functionals
  + X-ray absorption spectroscopy (XAS) with TDDFT
  + Analytical gradients for the COSMO solvation model
  + Transition densities from TDDFT 
  + DFT+U and Electron-Transfer (ET) methods for plane wave calculations
  + Exploitation of space group symmetry in plane wave geometry optimizations
  + Local density of states (LDOS) collective variable added to Metadynamics
  + Various new XC functionals added for plane wave calculations, including
    hybrid and range-corrected ones
  + Electric field gradients with relativistic corrections 
  + Nudged Elastic Band optimization method
  + Updated basis sets and ECPs 

[ Daniel Leidert ]
* debian/watch: Fixed.

[ Andreas Tille ]
* debian/upstream: References

[ Michael Banck ]
* debian/upstream (Name): New field.
* debian/patches/02_makefile_flags.patch: Refreshed.
* debian/patches/06_statfs_kfreebsd.patch: Likewise.
* debian/patches/07_ga_target_force_linux.patch: Likewise.
* debian/patches/05_avoid_inline_assembler.patch: Removed, no longer needed.
* debian/patches/09_backported_6.1.1_fixes.patch: Likewise.
* debian/control (Build-Depends): Added gfortran-4.7 and gcc-4.7.
* debian/patches/10_force_gcc-4.7.patch: New patch, explicitly sets
  gfortran-4.7 and gcc-4.7, fixes test suite hang with gcc-4.8 (Closes:
  #701328, #713262).
* debian/testsuite: Added tests for COSMO analytical gradients and MRCC.
* debian/rules (MRCC_METHODS): New variable, required to enable MRCC methods.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import time
2
 
import sys
3
 
#import numpy as np
4
 
import ga.gain as np
5
 
from ga.gain import me
6
 
 
7
 
def jacobi(A, B, tol=0.005, forcedIter=0):
8
 
    '''itteratively solving for matrix A with solution vector B
9
 
       tol = tolerance for dh/h
10
 
       init_val = array of initial values to use in the solver
11
 
    '''
12
 
    h = np.zeros(np.shape(B), float)
13
 
    dmax = 1.0
14
 
    n = 0
15
 
    tmp0 = np.empty(np.shape(A), float)
16
 
    tmp1 = np.empty(np.shape(B), float)
17
 
    AD = np.diagonal(A)
18
 
    #np.timer_reset()
19
 
    #np.evalflush()
20
 
    t1 = time.time()
21
 
    while (forcedIter and forcedIter > n) or \
22
 
          (forcedIter == 0 and dmax > tol):
23
 
        n += 1
24
 
        np.multiply(A,h,tmp0)
25
 
        np.add.reduce(tmp0,1,out=tmp1)
26
 
        tmp2 = AD
27
 
        np.subtract(B, tmp1, tmp1)
28
 
        np.divide(tmp1, tmp2, tmp1)
29
 
        hnew = h + tmp1
30
 
        np.subtract(hnew,h,tmp2)
31
 
        np.divide(tmp2,h,tmp1)
32
 
        np.absolute(tmp1,tmp1)
33
 
        dmax = np.maximum.reduce(tmp1)
34
 
        h = hnew
35
 
        print dmax
36
 
 
37
 
 
38
 
    #np.evalflush()
39
 
    t1 = time.time() - t1
40
 
 
41
 
    print 'Iter: ', n, ' size: ', np.shape(B),' time: ', t1,
42
 
    print "(Dist) notes: %s"%sys.argv[4]
43
 
    #if A.dist():
44
 
    #    print "(Dist) notes: %s"%sys.argv[4]
45
 
    #else:
46
 
    #    print "(Non-Dist) notes: %s"%sys.argv[4]
47
 
 
48
 
 
49
 
    return h
50
 
 
51
 
def main():
52
 
    d = int(sys.argv[1])
53
 
    size = int(sys.argv[2])
54
 
    iter = int(sys.argv[3])
55
 
 
56
 
    #A = array([[4, -1, -1, 0], [-1, 4, 0, -1], [-1, 0, 4, -1], [0, -1, -1, 4]], float, dist=d)
57
 
    #B = array([1,2,0,1], float, dist=d)
58
 
 
59
 
    #A = np.zeros([size,size], dtype=float)
60
 
    #np.ufunc_random(A,A)
61
 
    A = np.random.random_sample([size,size])
62
 
 
63
 
    #B = np.zeros([size], dtype=float)
64
 
    #np.ufunc_random(B,B)
65
 
    B = np.random.random_sample([size])
66
 
 
67
 
    C = jacobi(A, B, 0.10, forcedIter=iter)
68
 
 
69
 
if __name__ == '__main__':
70
 
    #import cProfile
71
 
    #cProfile.run("main()", "profile.%s.prof" % str(me()))
72
 
    main()