JuliaAtoms / AtomicLevels.jl

https://juliaatoms.org/AtomicLevels.jl
Other
12 stars 3 forks source link

WIP: Implemented optional unordered configurations #38

Closed jagot closed 5 years ago

jagot commented 5 years ago

The change was smaller than I anticipated. What remains to be implemented is printing of unsorted spin-configurations:

julia> replace(spin_configurations(c"[Ne]*" + Configuration(o"3s", 2, :open, true))[1], SpinOrbital(o"2s", 0, false)=>SpinOrbital(o"3p", 1, true))
1s² 2s₀α 2p⁶ 3s² 3p₁α

julia> replace(spin_configurations(c"[Ne]*" + Configuration(o"3s", 2, :open, false))[1], SpinOrbital(o"2s", 0, false)=>SpinOrbital(o"3p", 1, true))
1s₀α 1s₀β 2s₀α 3p₁α 2p₋₁α 2p₋₁β 2p₀α 2p₀β 2p₁α 2p₁β 3s₀α 3s₀β

and maybe if we want to extend the configuration string macro to handle unsorted configurations (e.g. c"1s2;"?)

jagot commented 5 years ago

This is now dependent on #44 being merged first. The tests are semi-fixed, until excited_configurations properly accounts for excitation orbital ordering, i.e. does not generate 2p 2p- and 2p- 2p (which although being distinct, are not linearly independent).

codecov[bot] commented 5 years ago

Codecov Report

Merging #38 into master will increase coverage by 0.7%. The diff coverage is 98.91%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #38     +/-   ##
=========================================
+ Coverage   90.65%   91.35%   +0.7%     
=========================================
  Files          15       15             
  Lines         749      810     +61     
=========================================
+ Hits          679      740     +61     
  Misses         70       70
Impacted Files Coverage Δ
src/AtomicLevels.jl 100% <ø> (+25%) :arrow_up:
src/excited_configurations.jl 100% <100%> (ø) :arrow_up:
src/orbitals.jl 94.39% <100%> (+0.05%) :arrow_up:
src/configurations.jl 98.66% <97.29%> (-0.27%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2690274...6698541. Read the comment docs.

jagot commented 5 years ago

@mortenpi 3b73488 implements the prioritization of orbitals (the order is first the orbitals in the starting configuration, then the order of the substitution orbitals given) we discussed earlier, but it had the unfortunate side effect of breaking this:

julia> gst = spin_configurations(Configuration(o"1s", 2, :open, sorted=false))[1]
1s₀α 1s₀β

julia> orbitals = reduce(vcat, spin_orbitals.(os"2[s]"))
2-element Array{SpinOrbital{Orbital{Int64}},1}:
 2s₀α
 2s₀β

julia> cs = excited_configurations(gst, orbitals...)
6-element Array{Configuration{SpinOrbital{Orbital{Int64}}},1}:
 1s₀α 1s₀β
 1s₀α 2s₀α
 1s₀α 2s₀β
 1s₀β 2s₀α
 1s₀β 2s₀β
 2s₀α 2s₀β

The configurations I want, and arguably the reason for this PR, are:

julia> vcat(gst, [replace(gst, gst.orbitals[1]=>o) for o in orbitals], [replace(gst, gst.orbitals[2]=>o) for o in orbitals], Configuration(orbitals, [1,1]))
6-element Array{Configuration{SpinOrbital{Orbital{Int64}}},1}:
 1s₀α 1s₀β
 2s₀α 1s₀β
 2s₀β 1s₀β
 1s₀α 2s₀α
 1s₀α 2s₀β
 2s₀α 2s₀β

i.e., in-place substitution. At the moment, when I need it, I'm doing these replacements anyway, so it is not a dealbreaker, but I wish it could be solved somehow.

mortenpi commented 5 years ago

For the in-place substitutions: should there just be two different excitation routines? Is it fair to say that (1) in-place excitations generally only work for the fully-qualified (spin-)orbitals, and (2) even then there are cases where you can't uniquely determine what the result should be (I seem to remember something like that vaguely)?

jagot commented 5 years ago

Fair enough, but did you not want the possibility of generating arbitrary CSFs, i.e. with any order of the configurations? Or did that exclude in-place excitations? I.e., do you ever want to generate 3s 2p starting from 1s 2p and exciting to 3s? Or is 2p 3s "good enough"?

mortenpi commented 5 years ago

I want the Configuration and CSF objects to be able to represent configurations/CSFs with orbitals in any order. That is not related to excitation generation though.

jagot commented 5 years ago

@mortenpi While working on a better implementation for excited_configurations for SpinOrbitals, I discovered the following:

julia> excited_configurations(c"[Ne]*", os"3[s-d]"..., keep_parity=false)
22-element Array{Configuration{Orbital{Int64}},1}:
 1s² 2s² 2p⁶      
 1s² 2s² 2p⁵ 3s   
 1s² 2s² 2p⁵ 3p   
 1s² 2s² 2p⁵ 3d   
 1s 2s² 2p⁶ 3s    
 1s 2s² 2p⁵ 3s²   
 1s² 2s 2p⁶ 3s    
 1s² 2s 2p⁵ 3s²   
 1s² 2s² 2p⁴ 3s²  
 1s 2s² 2p⁶ 3p    
 1s 2s² 2p⁵ 3p²   
 1s² 2s 2p⁶ 3p    
 1s² 2s 2p⁵ 3p²   
 1s² 2s² 2p⁴ 3s 3p
 1s² 2s² 2p⁴ 3p²  
 1s 2s² 2p⁶ 3d    
 1s 2s² 2p⁵ 3d²   
 1s² 2s 2p⁶ 3d    
 1s² 2s 2p⁵ 3d²   
 1s² 2s² 2p⁴ 3s 3d
 1s² 2s² 2p⁴ 3p 3d
 1s² 2s² 2p⁴ 3d²

i.e., since the core orbitals occur before the substitution orbitals, the former are prioritized over the latter and thus excitation from the core orbitals is not allowed. By specifying the reference set as a sorted configuration, this can be circumvented, as below, but I am not sure if this is what we want.

julia> excited_configurations(c"[Ne]*"s, os"3[s-d]"..., keep_parity=false)
46-element Array{Configuration{Orbital{Int64}},1}:
 1s² 2s² 2p⁶      
 1s 2s² 2p⁶ 3s    
 1s 2s² 2p⁶ 3p    
 1s 2s² 2p⁶ 3d    
 1s² 2s 2p⁶ 3s    
 1s² 2s 2p⁶ 3p    
 1s² 2s 2p⁶ 3d    
 1s² 2s² 2p⁵ 3s   
 1s² 2s² 2p⁵ 3p   
 1s² 2s² 2p⁵ 3d   
 2s² 2p⁶ 3s²      
 2s² 2p⁶ 3s 3p    
 2s² 2p⁶ 3s 3d    
 1s 2s 2p⁶ 3s²    
 1s 2s 2p⁶ 3s 3p  
 1s 2s 2p⁶ 3s 3d  
 1s 2s² 2p⁵ 3s²   
 1s 2s² 2p⁵ 3s 3p 
 1s 2s² 2p⁵ 3s 3d 
 2s² 2p⁶ 3p²      
 2s² 2p⁶ 3p 3d    
 1s 2s 2p⁶ 3p²    
 1s 2s 2p⁶ 3p 3d  
 1s 2s² 2p⁵ 3p²   
 1s 2s² 2p⁵ 3p 3d 
 2s² 2p⁶ 3d²      
 1s 2s 2p⁶ 3d²    
 1s 2s² 2p⁵ 3d²   
 1s² 2p⁶ 3s²      
 1s² 2p⁶ 3s 3p    
 1s² 2p⁶ 3s 3d    
 1s² 2s 2p⁵ 3s²   
 1s² 2s 2p⁵ 3s 3p 
 1s² 2s 2p⁵ 3s 3d 
 1s² 2p⁶ 3p²      
 1s² 2p⁶ 3p 3d    
 1s² 2s 2p⁵ 3p²   
 1s² 2s 2p⁵ 3p 3d 
 1s² 2p⁶ 3d²      
 1s² 2s 2p⁵ 3d²   
 1s² 2s² 2p⁴ 3s²  
 1s² 2s² 2p⁴ 3s 3p
 1s² 2s² 2p⁴ 3s 3d
 1s² 2s² 2p⁴ 3p²  
 1s² 2s² 2p⁴ 3p 3d
 1s² 2s² 2p⁴ 3d²