From 759baabb93e73b29ef68d141cb8572b756d53904 Mon Sep 17 00:00:00 2001 From: David Bowler Date: Thu, 5 Dec 2024 14:48:20 +0000 Subject: [PATCH] Initial atomic spin only set for spin polarised calculations The atomic spin was being read without testing for an overall spin polarised calculation, leading to the initial atomic spin flag being set and a crash. Now fixed. --- src/initial_read_module.f90 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/initial_read_module.f90 b/src/initial_read_module.f90 index 5febff318..a515f72b8 100644 --- a/src/initial_read_module.f90 +++ b/src/initial_read_module.f90 @@ -1362,7 +1362,7 @@ subroutine read_input(start, start_L, titles, vary_mu,& !maxnsf = 0 !max_rc = zero min_blip_sp = 1.0e8_double - flag_InitialAtomicSpin = .false. + flag_InitialAtomicSpin = .false. do i=1,n_species charge(i) = zero charge_up(i) = zero @@ -1383,13 +1383,15 @@ subroutine read_input(start, start_L, titles, vary_mu,& ! do while(fdf_bline(bp,line)) ! While there are lines in the block if(fdf_block(species_label(i))) then !charge(i) = fdf_double ('Atom.ValenceCharge',zero) - charge_up(i) = fdf_double ('Atom.SpinNeUp',zero) - charge_dn(i) = fdf_double ('Atom.SpinNeDn',zero) - sum_elecN_spin = charge_up(i)+charge_dn(i) - if (abs(sum_elecN_spin)>RD_ERR) then - flag_InitialAtomicSpin = .true. - ! We will check that the sum of charge_up and charge_dn matches charge later - endif + if(flag_spin_polarisation) then + charge_up(i) = fdf_double ('Atom.SpinNeUp',zero) + charge_dn(i) = fdf_double ('Atom.SpinNeDn',zero) + sum_elecN_spin = charge_up(i)+charge_dn(i) + if (abs(sum_elecN_spin)>RD_ERR) then + flag_InitialAtomicSpin = .true. + ! We will check that the sum of charge_up and charge_dn matches charge later + endif + end if nsf_species(i) = fdf_integer('Atom.NumberOfSupports',0) RadiusSupport(i) = fdf_double ('Atom.SupportFunctionRange',zero) !RadiusAtomf(i) = RadiusSupport(i) ! = r_pao for (atomf=paof) or r_sf for (atomf==sf)