MATLAB Examples

bond_valence_atom.m

  • This function tries to calculate the bond valence values
  • atom is the atom struct
  • Box_dim is the box dimension vector
  • Tested 15/04/2017
  • Please report bugs to michael.holmboe@umu.se

Contents

Examples

  • atom = bond_valence_atom(atom,Box_dim)
  • atom = bond_valence_atom(atom,Box_dim,1.25,2.25) % the maximum O-H bond and the M-O distances in the neighbout search
function atom = bond_valence_atom(atom,Box_dim,varargin)

if nargin>2
    max_short_dist=varargin{1};
    max_long_dist=varargin{2};
else
    max_short_dist=1.25;
    max_long_dist=2.25;
end

load('bond_valence_values.mat');
atom=element_atom(atom);
[atom.type]=atom.element;
atom=bond_angle_atom(atom,Box_dim,max_short_dist,max_long_dist,'more');

for i=1:size(atom,2)
    for j=1:size(atom(i).neigh.type,1)
        [mean_bv,std_bv,bv]=bond_valence_data(atom(i).type,atom(i).neigh.type(j),atom(i).neigh.dist(j),Ion_1,Ion_2,R0,b);
        atom(i).bv(j)=mean_bv;
    end

    atom(i).valence=sum(atom(i).bv(:));
    size(atom(i).neigh.type,1)
    atom(i).Rdiff=-0.37*log(atom(i).valence/round([atom(i).valence])); % R - RO i.e. actual minus ideal bond distance
    if mod(i,100)==0
        i
    end
end


A=round([atom.valence]);
B=[atom.valence];
C(1:2:2*numel(A))=A;
C(2:2:2*numel(A))=B;
C

disp('    Mean   |  Median  |  std ')
[mean([atom.valence]-round([atom.valence])) median([atom.valence]-round([atom.valence])) std([atom.valence]-round([atom.valence]))]