mass_atom.m

Contents

Version

2.11

Contact

Please report problems/bugs to michael.holmboe@umu.se

Examples

  1. atom = mass_atom(atom)
  2. atom = mass_atom(atom,Box_dim) % To calculate the density
function atom = mass_atom(atom,varargin)
element=element_atom(atom);

mass={...
    1.00794 'Hydrogen' 'H' 1 ;...
    4.0026 'Helium' 'He' 2 ;...
    6.941 'Lithium' 'Li' 3 ;...
    9.0122 'Beryllium' 'Be' 4 ;...
    10.811 'Boron' 'B' 5 ;...
    12.0107 'Carbon' 'C' 6 ;...
    14.0067 'Nitrogen' 'N' 7 ;...
    15.9994 'Oxygen' 'O' 8 ;...
    18.9984 'Fluorine' 'F' 9 ;...
    20.1797 'Neon' 'Ne' 10 ;...
    22.9897 'Sodium' 'Na' 11 ;...
    24.305 'Magnesium' 'Mg' 12 ;...
    26.9815 'Aluminum' 'Al' 13 ;...
    28.0855 'Silicon' 'Si' 14 ;...
    30.9738 'Phosphorus' 'P' 15 ;...
    32.065 'Sulfur' 'S' 16 ;...
    35.453 'Chlorine' 'Cl' 17 ;...
    39.0983 'Potassium' 'K' 19 ;...
    39.948 'Argon' 'Ar' 18 ;...
    40.078 'Calcium' 'Ca' 20 ;...
    44.9559 'Scandium' 'Sc' 21 ;...
    47.867 'Titanium' 'Ti' 22 ;...
    50.9415 'Vanadium' 'V' 23 ;...
    51.9961 'Chromium' 'Cr' 24 ;...
    54.938 'Manganese' 'Mn' 25 ;...
    55.845 'Iron' 'Fe' 26 ;...
    58.6934 'Nickel' 'Ni' 28 ;...
    58.9332 'Cobalt' 'Co' 27 ;...
    63.546 'Copper' 'Cu' 29 ;...
    65.39 'Zinc' 'Zn' 30 ;...
    69.723 'Gallium' 'Ga' 31 ;...
    72.64 'Germanium' 'Ge' 32 ;...
    74.9216 'Arsenic' 'As' 33 ;...
    78.96 'Selenium' 'Se' 34 ;...
    79.904 'Bromine' 'Br' 35 ;...
    83.8 'Krypton' 'Kr' 36 ;...
    85.4678 'Rubidium' 'Rb' 37 ;...
    87.62 'Strontium' 'Sr' 38 ;...
    88.9059 'Yttrium' 'Y' 39 ;...
    91.224 'Zirconium' 'Zr' 40 ;...
    92.9064 'Niobium' 'Nb' 41 ;...
    95.94 'Molybdenum' 'Mo' 42 ;...
    98 'Technetium' 'Tc' 43 ;...
    101.07 'Ruthenium' 'Ru' 44 ;...
    102.9055 'Rhodium' 'Rh' 45 ;...
    106.42 'Palladium' 'Pd' 46 ;...
    107.8682 'Silver' 'Ag' 47 ;...
    112.411 'Cadmium' 'Cd' 48 ;...
    114.818 'Indium' 'In' 49 ;...
    118.71 'Tin' 'Sn' 50 ;...
    121.76 'Antimony' 'Sb' 51 ;...
    126.9045 'Iodine' 'I' 53 ;...
    127.6 'Tellurium' 'Te' 52 ;...
    131.293 'Xenon' 'Xe' 54 ;...
    132.9055 'Cesium' 'Cs' 55 ;...
    137.327 'Barium' 'Ba' 56 ;...
    138.9055 'Lanthanum' 'La' 57 ;...
    140.116 'Cerium' 'Ce' 58 ;...
    140.9077 'Praseodymium' 'Pr' 59 ;...
    144.24 'Neodymium' 'Nd' 60 ;...
    145 'Promethium' 'Pm' 61 ;...
    150.36 'Samarium' 'Sm' 62 ;...
    151.964 'Europium' 'Eu' 63 ;...
    157.25 'Gadolinium' 'Gd' 64 ;...
    158.9253 'Terbium' 'Tb' 65 ;...
    162.5 'Dysprosium' 'Dy' 66 ;...
    164.9303 'Holmium' 'Ho' 67 ;...
    167.259 'Erbium' 'Er' 68 ;...
    168.9342 'Thulium' 'Tm' 69 ;...
    173.04 'Ytterbium' 'Yb' 70 ;...
    174.967 'Lutetium' 'Lu' 71 ;...
    178.49 'Hafnium' 'Hf' 72 ;...
    180.9479 'Tantalum' 'Ta' 73 ;...
    183.84 'Tungsten' 'W' 74 ;...
    186.207 'Rhenium' 'Re' 75 ;...
    190.23 'Osmium' 'Os' 76 ;...
    192.217 'Iridium' 'Ir' 77 ;...
    195.078 'Platinum' 'Pt' 78 ;...
    196.9665 'Gold' 'Au' 79 ;...
    200.59 'Mercury' 'Hg' 80 ;...
    204.3833 'Thallium' 'Tl' 81 ;...
    207.2 'Lead' 'Pb' 82 ;...
    208.9804 'Bismuth' 'Bi' 83 ;...
    209 'Polonium' 'Po' 84 ;...
    210 'Astatine' 'At' 85 ;...
    222 'Radon' 'Rn' 86 ;...
    223 'Francium' 'Fr' 87 ;...
    226 'Radium' 'Ra' 88 ;...
    227 'Actinium' 'Ac' 89 ;...
    231.0359 'Protactinium' 'Pa' 91 ;...
    232.0381 'Thorium' 'Th' 90 ;...
    237 'Neptunium' 'Np' 93 ;...
    238.0289 'Uranium' 'U' 92 ;...
    243 'Americium' 'Am' 95 ;...
    244 'Plutonium' 'Pu' 94 ;...
    247 'Curium' 'Cm' 96 ;...
    247 'Berkelium' 'Bk' 97 ;...
    251 'Californium' 'Cf' 98 ;...
    252 'Einsteinium' 'Es' 99 ;...
    257 'Fermium' 'Fm' 100 ;...
    258 'Mendelevium' 'Md' 101 ;...
    259 'Nobelium' 'No' 102 ;...
    261 'Rutherfordium' 'Rf' 104 ;...
    262 'Lawrencium' 'Lr' 103 ;...
    262 'Dubnium' 'Db' 105 ;...
    264 'Bohrium' 'Bh' 107 ;...
    266 'Seaborgium' 'Sg' 106 ;...
    268 'Meitnerium' 'Mt' 109 ;...
    272 'Roentgenium' 'Rg' 111 ;...
    277 'Hassium' 'Hs' 108 ;...
    };

ind=[];ind_array=[];
if iscell([element.type]) && length([element.type]) > 1
    for i=1:length([element.type])
        ind=find(strncmpi([element(i).type],mass(:,3),2));
        if numel(ind) == 0
            ind=find(strncmpi([element(i).type],mass(:,3),1));
            if numel(ind) == 0
                disp('Could not find mass for')
                disp([element(i).type])
                disp('setting it to 10 au')
                ind = 6;
            end
        end
        ind_array=[ind_array ind(1)];
    end
    ind=ind_array;
else
    ind=find(strcmpi([element.type],mass(:,1)))
    if numel(ind) == 0
        ind = 6;
    end
end

atnum = cell2mat(mass(ind,4));
mass = cell2mat(mass(ind,1));
for i=1:length([atom.type])
    [atom(i).mass]=mass(i);
    [atom(i).atnum]=atnum(i);
end

Set the occupancy of all sites

occ=1;
if ~isfield(atom,'occupancy')
    occ=1;
    try
        atom = occupancy_atom(atom,Box_dim);
    catch
        [atom.occupancy]=deal(1);
    end
end

% disp('Molecular weight in g/mol, Mw:')
Mw=sum([atom.mass]);
% disp('Molecular weight in g/mol, considering Mw_occupancy:')
Mw_occupancy=sum([atom.mass].*[atom.occupancy]);

if nargin>1
    Box_dim=varargin{1};

    lx=Box_dim(1);
    ly=Box_dim(2);
    lz=Box_dim(3);
    if size(Box_dim,2)==9
        xy=Box_dim(6);
        xz=Box_dim(8);
        yz=Box_dim(9);
    else
        xy=0;
        xz=0;
        yz=0;
    end
    a=lx;
    b=(ly^2+xy^2)^.5;
    c=(lz^2+xz^2+yz^2)^.5;
    alfa=rad2deg(acos((ly*yz+xy*xz)/(b*c)));
    beta=rad2deg(acos(xz/c));
    gamma=rad2deg(acos(xy/b));

    Box_volume=a*b*c*(1 - cos(deg2rad(alfa))^2 - cos(deg2rad(beta))^2 - cos(deg2rad(gamma))^2 + 2*cos(deg2rad(alfa))*cos(deg2rad(beta))*cos(deg2rad(gamma)))^.5;
    Box_density=Mw_occupancy/6.022E23/(Box_volume*1E-24);
%     disp('Volume in Å^3:')
%     Box_volume
%     disp('Density in g/cm^3')
%     Box_density
    assignin('caller','Box_volume',Box_volume);
    assignin('caller','Box_density',Box_density);
end

assignin('caller','Mw',Mw);
assignin('caller','Mw_occupancy',Mw_occupancy);

if occ==0
    atom = rmfield(atom,'occupancy');
end