To define compute/atom mass

Hello all.

I tried to make cascade simulation in ternary system.
I want to select random PKA atom and want to define its mass.
So first I select ID of random PKA atom by using command

# Selecting a random PKA
variable    tempID equal ceil(random(0,${n_atoms}-1,${i}*23782+19772))
variable    pkaID  equal ${tempID}
group       PKA    id ${pkaID}

Then I want to derive its mass by using

compute     massPKA PKA property/atom mass

Then I want to use its value for variable by using

variable    PKAmass  equal c_massPKA

But it didn’t work. I don’t know what is problem

Can anybody help me please?

What do you mean by “it didn’t work”?

Your post is inconsistent, too. At the beginning you talk about “defining” the mass of the PKA, but later you want to compute its mass. Please elaborate.

Sorry for the confusion.

You are right. My purpose is compute its mass

Before selecting PKA atom, I already defined its mass by input file command

LAMMPS data file written by OVITO Basic 3.7.12

  108000  atoms
       3  atom types

  0.000000000000     107.185762000000  xlo xhi
  0.000000000000     107.186759000000  ylo yhi
  0.000000000000     107.181923000000  zlo zhi

Masses

        1   58.69340000             # Ni
        2   58.93319500             # Co
        3   51.99610000             # Cr

And my purpose is to derive mass of the PKA.

I thought by using compute propert/atom and variable command, I could make PKAmass equal to mass of PKA.

But I can’t use variable PKAmass in after calculation.

#PKA Velocity
variable E_PKAJ equal ${E_PKA} * 1.60218 * 1e-19

variable E_PKAJ equal 1000 * 1.60218 * 1e-19

variable MassKg equal ${PKAmass} * 1.66054 * 1e-27

ERROR: Variable PKAmass: Invalid thermo keyword ‘massPKA’ in variable formula (…/variable.cpp:2110)

Last command: variable MassKg equal ${PKAmass} * 1.66054 * 1e-27

I think I have some miss usage in format of computed mass.

Here is a serious problem: you are trying to use a per-atom property in a global expression.
Also, other lines of your input have syntax and semantics issues. You need to study the documentation more carefully. Specifically, you seem to be mixing up ${name} expansion of variables by the input pre-processor and v_name variable references in variable expressions.
Sometimes you need the former (if you want the current value at the time of definition only), and sometimes the other (if you want the value at the time when you retrieve the value of the variable).

Computing the mass of the PKA in your case is much simpler, since you defined a group for the PKA. Using:

variable PKAmass equal mass(PKA)

should do.

Now it work.

I really appreciate for your help!!

Have a nice day!