~siesta-ts/siesta/trunk_ts_soc

« back to all changes in this revision

Viewing changes to Src/save_density_matrix.F90

  • Committer: Nick Papior
  • Date: 2018-10-25 20:17:10 UTC
  • mfrom: (560.1.463 4.1)
  • Revision ID: nickpapior@gmail.com-20181025201710-y5u05fnigepa6lq0
Merged r1022-1023, grid-cell-sampling grid and TSDE writes for fixspin

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
    ! Eventually it can be a cleaner routine
20
20
    
21
21
    use precision,            only:  dp
 
22
    use class_dSpData2D,      only:  val
22
23
    use sparse_matrices,      only:  maxnh
23
24
#ifdef TIMING_IO
24
25
    use sparse_matrices,      only:  numh
32
33
    use siesta_geom,          only:  nsc
33
34
    use siesta_options,       only:  writedm, writedm_cdf
34
35
    use siesta_options,       only:  writedm_cdf_history
35
 
    use siesta_options,       only:  idyn, nmove
 
36
    use siesta_options,       only:  idyn, nmove, fixspin
36
37
    use m_steps,              only:  istp
37
38
    use sparse_matrices,      only:  Dscf, DM_2D
38
39
    use fdf,                  only:  fdf_get
48
49
    use m_ts_iodm,            only:  write_ts_dm
49
50
    use m_ts_global_vars,     only:  TSrun
50
51
    use m_ts_options,         only:  TS_DE_save
51
 
    use m_energies,           only:  Ef
 
52
    use m_energies,           only:  Ef, Efs
52
53
 
53
54
    implicit none
54
55
    
55
56
    logical, intent(in) :: SCFconverged
56
57
    logical, intent(in), optional  :: when
57
58
    character(len=*), intent(in), optional   :: file
 
59
 
 
60
    real(dp), pointer :: EDM(:, :), DM(:,:)
58
61
    
59
62
    logical :: do_write
60
63
    
147
150
    end if
148
151
 
149
152
    if ( do_write ) then
 
153
      if ( fixspin ) then
 
154
        ! For fixed spin calculations we shift the energy-density according
 
155
        ! to the first spin
 
156
        DM => val(DM_2D)
 
157
        EDM => val(EDM_2D)
 
158
        call daxpy(size(DM,1),Efs(1)-Efs(2),DM(1,2),1,EDM(1,2),1)
 
159
        Ef = Efs(1)
 
160
      end if
150
161
      call write_ts_dm(trim(slabel)//'.TSDE', nsc, DM_2D, EDM_2D, Ef)
 
162
      if ( fixspin ) then
 
163
        ! Shift back
 
164
        call daxpy(size(DM,1),Efs(2)-Efs(1),DM(1,2),1,EDM(1,2),1)
 
165
      end if
151
166
    end if
152
167
    
153
168
  end subroutine save_density_matrix