Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String macros for spin-orbitals and spin-configurations #41

Closed
jagot opened this issue Jun 4, 2019 · 2 comments
Closed

String macros for spin-orbitals and spin-configurations #41

jagot opened this issue Jun 4, 2019 · 2 comments

Comments

@jagot
Copy link
Member

jagot commented Jun 4, 2019

I find that I miss these from time to time, i.e. so"1s0α" and sc"1s0α 2p-1β", or something along those lines. Ties in with #24 and #36. #21 should probably be resolved before, to reduce confusion (alternative notation for the m quantum number of a spin-orbital could be e.g. sc"2p(-1)β").

@mortenpi
Copy link
Member

The macro for orbitals was added in #88, but a macro for configurations is still on the TODO?

@jagot
Copy link
Member Author

jagot commented Mar 22, 2021

That's right; I wanted to generalize the current functionality for parse strings into configurations:

function Base.parse(::Type{Configuration{O}}, conf_str::AbstractString; sorted=false) where {O<:AbstractOrbital}
isempty(conf_str) && return Configuration{O}(sorted=sorted)
orbs = split(conf_str, r"[\. ]")
core_m = match(r"\[([a-zA-Z]+)\]([*ci]{0,1})", first(orbs))
if core_m != nothing
core_config = core_configuration(O, core_m[1], core_m[2], sorted)
if length(orbs) > 1
peel_config = Configuration(parse_orbital.(Ref(O), orbs[2:end]))
Configuration(vcat(core_config.orbitals, peel_config.orbitals),
vcat(core_config.occupancy, peel_config.occupancy),
vcat(core_config.states, peel_config.states),
sorted=sorted)
else
core_config
end
else
Configuration(parse_orbital.(Ref(O), orbs), sorted=sorted)
end
end

to work with spin-configurations as well, but I got a bit stuck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants