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

Document use of rc to add pseudo-atoms in Molecules #236

Closed
qlx17 opened this issue Jun 23, 2024 · 3 comments
Closed

Document use of rc to add pseudo-atoms in Molecules #236

qlx17 opened this issue Jun 23, 2024 · 3 comments

Comments

@qlx17
Copy link

qlx17 commented Jun 23, 2024

I would like to define a nitrogen molecule with charges derived from the TraPPE force field. In this setup, point charges of -0.482e are placed on the two nitrogen atoms, and to maintain charge neutrality, a point charge of +0.964e is placed at the center of mass of the nitrogen molecule. This dummy site should have zero mass. Here are my atoms.csv and charges.csv files:

atoms.csv

atom,x,y,z
N_in_N2,0,0,0.55
VOID,0,0,0
N_in_N2,0,0,-0.55

charges.csv

q,x,y,z
-0.482,0,0,0.55
0.964,0,0,0
-0.482,0,0,-0.55

However, when I run molecule = Molecule("N2"), I encounter the following error:

ERROR: KeyError: key :VOID not found
Stacktrace:
  [1] getindex(h::Dict{Symbol, Float64}, key::Symbol)
    @ Base ./dict.jl:484
  [2] (::PorousMaterials.var"#12#13")(x::Symbol)
    @ PorousMaterials ./none:0
  [3] iterate
    @ ./generator.jl:47 [inlined]
  [4] collect_to!(dest::Vector{Float64}, itr::Base.Generator{Vector{Symbol}, PorousMaterials.var"#12#13"}, offs::Int64, st::Int64)
    @ Base ./array.jl:840
  [5] collect_to_with_first!(dest::Vector{Float64}, v1::Float64, itr::Base.Generator{Vector{Symbol}, PorousMaterials.var"#12#13"}, st::Int64)
    @ Base ./array.jl:818
  [6] collect(itr::Base.Generator{Vector{Symbol}, PorousMaterials.var"#12#13"})
    @ Base ./array.jl:792
  [7] center_of_mass(molecule::Molecule{Cart})
    @ PorousMaterials ~/.julia/packages/PorousMaterials/R2E9b/src/molecule.jl:25
  [8] Molecule(species::String; check_neutrality::Bool)
    @ PorousMaterials ~/.julia/packages/PorousMaterials/R2E9b/src/molecule.jl:82
  [9] Molecule(species::String)
    @ PorousMaterials ~/.julia/packages/PorousMaterials/R2E9b/src/molecule.jl:56
 [10] top-level scope
    @ REPL[10]:1

I believe this error occurs because the atomic mass of VOID is not defined. I suggest adding the atomic mass of VOID as zero to the append_atomic_masses() function so that a more general molecule definition can be supported.

@eahenle
Copy link
Collaborator

eahenle commented Jun 23, 2024

We don't include anything like :VOID in the mass list, because some people call it that, others call it :X, still others might call it :None, etc. The user should set whichever one of these they intend to use by adding it to the (exported, global) rc dictionary before calling Molecule:

rc[:atomic_masses][:VOID] = 0.

@eahenle eahenle closed this as completed Jun 23, 2024
@qlx17
Copy link
Author

qlx17 commented Jun 24, 2024

Thanks for your explanation. That is a more general way to add custom atomic masses. Perhaps this should be documented in the molecules chapter of the documentation?

@eahenle
Copy link
Collaborator

eahenle commented Jun 24, 2024

Yes, that is a very good idea.

@eahenle eahenle reopened this Jun 24, 2024
@eahenle eahenle changed the title Error when defining nitrogen molecule with dummy sites Document use of rc to add pseudo-atoms in Molecules Jun 24, 2024
This was referenced Jun 24, 2024
@eahenle eahenle closed this as completed Jun 26, 2024
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

Successfully merging a pull request may close this issue.

2 participants