Commit 11a4dbbe authored by Alberto Garcia's avatar Alberto Garcia
Browse files

Fix bug related to init_spin behavior

The PEXSI-only processes do not call 'init_spin', and rely on a
broadcast from the Siesta_worker nodes to get certain information. As
nspin, spinor_dim, et al were integer pointers in 'm_init', they were
undefined on entry to the PEXSI interface routines, causing segfaults.
They have been converted to plain integers for now, pending a review
of other possible ways to fix the problem. 

Some pointers in sparse_matrices have been initialized to null().

A test to catch non-collinear or spin-orbit cases has been added
before the call to the PEXSI solver.

Note that the PEXSI routines still use the 'nspin' variable internally
to refer to both 'spinor_dim' and 'h_spin_dim'. This will be changed when
mixed-spin solving is implemented.

Added Tests/sih-pexsi-spin.

modified:
  Src/compute_dm.F
  Src/m_spin.F90
  Src/siesta_analysis.F
  Src/sparse_matrices.F
added:
  Tests/sih-pexsi-spin


parent 3632a252
------------------------------------------------------------
July 31, 2016 A. Garcia trunk-537--pexsi-v0.8-spin-13
Fix bug related to init_spin behavior
The PEXSI-only processes do not call 'init_spin', and rely on a
broadcast from the Siesta_worker nodes to get certain information. As
nspin, spinor_dim, et al were integer pointers in 'm_init', they were
undefined on entry to the PEXSI interface routines, causing segfaults.
They have been converted to plain integers for now, pending a review
of other possible ways to fix the problem.
Some pointers in sparse_matrices have been initialized to null().
A test to catch non-collinear or spin-orbit cases has been added
before the call to the PEXSI solver.
Note that the PEXSI routines still use the 'nspin' variable internally
to refer to both 'spinor_dim' and 'h_spin_dim'. This will be changed when
mixed-spin solving is implemented.
Added Tests/sih-pexsi-spin.
modified:
Src/compute_dm.F
Src/m_spin.F90
Src/siesta_analysis.F
Src/sparse_matrices.F
added:
Tests/sih-pexsi-spin
------------------------------------------------------------
July 30, 2016 A. Garcia trunk-537--pexsi-v0.8-spin-12
Put back the MPI interfaces
......
......@@ -110,7 +110,14 @@
#ifdef PEXSI
if (isolve .eq. SOLVE_PEXSI) then
call pexsi_solver(iscf, no_u, no_l, nspin,
! This test done in node 0 since NonCol and SpOrb
! are not set for PEXSI-solver-only processes
if (ionode) then
if (NonCol .or. SpOrb) call die(
$ "The PEXSI solver does not implement "//
$ "non-coll spins or Spin-orbit yet")
endif
call pexsi_solver(iscf, no_u, no_l, spinor_dim,
$ maxnh, numh, listhptr, listh,
$ H, S, qtot, Dscf, Escf,
$ ef, Entropy, temp, delta_Ef)
......
......@@ -59,15 +59,23 @@ module m_spin
!> Spin configuration for SIESTA
type(tSpin), public :: spin
! Use plain integers instead of pointers, to avoid problems
! in the PEXSI-only nodes, which might not call the spin_init
! routine. The values are copied at the end of that routine.
! Create short-hands for the spin-configuration
! DO NOT USE THIS VARIABLE, USE -> type(tSpin) :: spin%Grid
integer, save, public, pointer :: nspin ! (Grid)
! integer, save, public, pointer :: nspin => null() ! (Grid)
integer, save, public :: nspin ! (Grid)
! DO NOT USE THIS VARIABLE, USE -> type(tSpin) :: spin%spinor
integer, save, public, pointer :: spinor_dim ! (spinor)
! integer, save, public, pointer :: spinor_dim => null() ! (spinor)
integer, save, public :: spinor_dim ! (spinor)
! DO NOT USE THIS VARIABLE, USE -> type(tSpin) :: spin%H, spin%DM
integer, save, public, pointer :: h_spin_dim ! (H and DM)
! integer, save, public, pointer :: h_spin_dim => null() ! (H and DM)
integer, save, public :: h_spin_dim ! (H and DM)
! DO NOT USE THIS VARIABLE, USE -> type(tSpin) :: spin%EDM
integer, save, public, pointer :: e_spin_dim ! (EDM)
! integer, save, public, pointer :: e_spin_dim => null() ! (EDM)
integer, save, public :: e_spin_dim ! (EDM)
! DO NOT USE THIS VARIABLE, USE -> type(tSpin) :: spin%none
......@@ -110,10 +118,10 @@ contains
character(len=32) :: opt
! Create pointer assignments...
call int_pointer(spinor_dim, spin%spinor)
call int_pointer(nspin , spin%grid)
call int_pointer(h_spin_dim, spin%H)
call int_pointer(e_spin_dim, spin%EDM)
!!$ call int_pointer(spinor_dim, spin%spinor)
!!$ call int_pointer(nspin , spin%grid)
!!$ call int_pointer(h_spin_dim, spin%H)
!!$ call int_pointer(e_spin_dim, spin%EDM)
! Create pointer assignments...
call log_pointer(NoMagn, spin%none)
......@@ -284,6 +292,11 @@ contains
call re_alloc(qs, 1, spin%spinor, &
name="qs",routine="init_spin")
nspin = spin%grid
h_spin_dim = spin%H
spinor_dim = spin%spinor
e_spin_dim = spin%EDM
contains
subroutine int_pointer(from, to)
......
......@@ -118,7 +118,7 @@
if (fdf_get("Read-H-from-file",.false.)) then
if (SIESTA_worker) then
call read_spmatrix(maxnh, no_l, nspin, numh,
call read_spmatrix(maxnh, no_l, h_spin_dim, numh,
. listhptr, listh, H, found, userfile="H_IN")
if (.not. found) call die("Could not find H_IN")
current_ef = ef
......@@ -128,7 +128,7 @@
#ifdef PEXSI
if (fdf_get("PEXSI.DOS",.false.)) then
call pexsi_dos(no_u, no_l, nspin,
call pexsi_dos(no_u, no_l, spinor_dim,
$ maxnh, numh, listhptr, listh, H, S, qtot, ef)
endif
......
......@@ -20,11 +20,12 @@
! Max. number of nonzero H matrix elements
integer, public :: maxnh = 10
integer, public, pointer :: listh(:), listhptr(:), numh(:)
integer, public, pointer :: listh(:)=>null(), listhptr(:)=>null(),
$ numh(:)=>null()
real(dp), public, pointer :: Dold(:,:), Dscf(:,:),
& Escf(:,:), H(:,:),
& xijo(:,:), S(:)
real(dp), public, pointer :: Dold(:,:)=>null(), Dscf(:,:)=>null(),
& Escf(:,:)=>null(), H(:,:)=>null(),
& xijo(:,:)=>null(), S(:)=>null()
! Used to hold the "input" H when mixing the Hamiltonian
real(dp), dimension(:,:), public, pointer :: Hold => null()
......
#
# Single-test makefile
#
name=sih-pexsi-spin
#
include ../test.mk
# -----------------------------------------------------------------------------
# FDF for interstitial H in a cubic c-Si supercell with 64 atoms
#
# E. Artacho, April 1999
# -----------------------------------------------------------------------------
#-------
## compute-forces F
SolutionMethod PEXSI
MPI.Nprocs.SIESTA 1
spin-polarized T
%block DM.InitSpin
65 +
%endblock DM.InitSpin
PEXSI.np-per-pole 2
PEXSI.num-poles 40
PEXSI.mu -0.30 Ry
PEXSI.num-electron-tolerance-upper-bound 0.01
PEXSI.num-electron-tolerance-lower-bound 1.0e-3
PEXSI.inertia-energy-width-tolerance 0.2 eV
PEXSI.inertia-mu-tolerance 0.2 eV
###PEXSI.num-electron-tolerance 1.0d-4
PEXSI.mu-max-iter 10
DM.NormalizationTolerance 1.0d-1 # (true_no_electrons/no_electrons) - 1.0
PEXSI.ordering 1 # Note this ... apparently needed for small npPerPole
PEXSI.verbosity 2
#------
#--------------
PEXSI.DOS T
PEXSI.LocalDOS T
PEXSI.LocalDOS.np-per-pole 20
PEXSI.LocalDOS.Energy -3.5141 eV
PEXSI.LocalDOS.Broadening 0.05 eV
WriteDMHS.NetCDF F
WriteDM.NetCDF F
WriteDM T
SystemName H in 64-atom silicon -- Spin Polarized -- PEXSI solver
SystemLabel sih-pexsi-spin
NumberOfAtoms 65
NumberOfSpecies 2
%block ChemicalSpeciesLabel
1 14 Si
2 1 H
%endblock ChemicalSpeciesLabel
PAO.BasisSize DZP
PAO.EnergyShift 300 meV
%block PAO.Basis
H 1
0 1
0.
0.8
%endblock PAO.Basis
LatticeConstant 5.430 Ang
%block LatticeVectors
2.000 0.000 0.000
0.000 2.000 0.000
0.000 0.000 2.000
%endblock LatticeVectors
MeshCutoff 100.0 Ry
MaxSCFIterations 20
DM.MixingWeight 0.3
DM.NumberPulay 4
DM.Tolerance 1.d-3
DM.UseSaveDM
ElectronicTemperature 25 meV
AtomicCoordinatesFormat ScaledCartesian
%block AtomicCoordinatesAndAtomicSpecies
0.000 0.000 0.000 1 # Si 1
0.250 0.250 0.250 1 # Si 2
0.000 0.500 0.500 1 # Si 3
0.250 0.750 0.750 1 # Si 4
0.500 0.000 0.500 1 # Si 5
0.750 0.250 0.750 1 # Si 6
0.500 0.500 0.000 1 # Si 7
0.750 0.750 0.250 1 # Si 8
1.000 0.000 0.000 1 # Si 9
1.250 0.250 0.250 1 # Si 10
1.000 0.500 0.500 1 # Si 11
1.250 0.750 0.750 1 # Si 12
1.500 0.000 0.500 1 # Si 13
1.750 0.250 0.750 1 # Si 14
1.500 0.500 0.000 1 # Si 15
1.750 0.750 0.250 1 # Si 16
0.000 1.000 0.000 1 # Si 17
0.250 1.250 0.250 1 # Si 18
0.000 1.500 0.500 1 # Si 19
0.250 1.750 0.750 1 # Si 20
0.500 1.000 0.500 1 # Si 21
0.750 1.250 0.750 1 # Si 22
0.500 1.500 0.000 1 # Si 23
0.750 1.750 0.250 1 # Si 24
0.000 0.000 1.000 1 # Si 25
0.250 0.250 1.250 1 # Si 26
0.000 0.500 1.500 1 # Si 27
0.250 0.750 1.750 1 # Si 28
0.500 0.000 1.500 1 # Si 29
0.750 0.250 1.750 1 # Si 30
0.500 0.500 1.000 1 # Si 31
0.750 0.750 1.250 1 # Si 32
1.000 1.000 0.000 1 # Si 33
1.250 1.250 0.250 1 # Si 34
1.000 1.500 0.500 1 # Si 35
1.250 1.750 0.750 1 # Si 36
1.500 1.000 0.500 1 # Si 37
1.750 1.250 0.750 1 # Si 38
1.500 1.500 0.000 1 # Si 39
1.750 1.750 0.250 1 # Si 40
1.000 0.000 1.000 1 # Si 41
1.250 0.250 1.250 1 # Si 42
1.000 0.500 1.500 1 # Si 43
1.250 0.750 1.750 1 # Si 44
1.500 0.000 1.500 1 # Si 45
1.750 0.250 1.750 1 # Si 46
1.500 0.500 1.000 1 # Si 47
1.750 0.750 1.250 1 # Si 48
0.000 1.000 1.000 1 # Si 49
0.250 1.250 1.250 1 # Si 50
0.000 1.500 1.500 1 # Si 51
0.250 1.750 1.750 1 # Si 52
0.500 1.000 1.500 1 # Si 53
0.750 1.250 1.750 1 # Si 54
0.500 1.500 1.000 1 # Si 55
0.750 1.750 1.250 1 # Si 56
1.000 1.000 1.000 1 # Si 57
1.250 1.250 1.250 1 # Si 58
1.000 1.500 1.500 1 # Si 59
1.250 1.750 1.750 1 # Si 60
1.500 1.000 1.500 1 # Si 61
1.750 1.250 1.750 1 # Si 62
1.500 1.500 1.000 1 # Si 63
1.750 1.750 1.250 1 # Si 64
1.125 1.125 1.125 2 # H 65
%endblock AtomicCoordinatesAndAtomicSpecies
trunk-537--pexsi-v0.8-spin-12
trunk-537--pexsi-v0.8-spin-13
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment