Orcaview; display only average A values

General forum for EasySpin: questions, how to's, etc.
Post Reply
Grahamhaug
Newbie
Posts: 1
Joined: Tue Sep 10, 2019 12:32 pm

Orcaview; display only average A values

Post by Grahamhaug »

Hello,

I am hoping to make a simple change to the OrcaView code to display only the average hyperfine values instead of the x, y, z, average currently displayed. I've successfully updated the font size to be more readable in my Excel spreadsheets but seeing only the average A values is my current priority. This is for ease of determining proton couplings compared to experimental/literature values/across many geometries optimized using different DFT XC functionals.

I believe this is the relevant section of the OrcaView code (I am a matlab beginner):
% Hyperfine
%---------------------------------------------------------------
if hyperfineDisplay || plotHFframe
A = thisdata.hfc{iAtom};
if isempty(A), continue; end
[V,E] = eig(A); A = diag(E);
[~,idx] = sort(abs(A)); A = A(idx); V = V(:,idx);
maxA = max(abs(A));
aboveThreshold = maxA > 1;
if hyperfineDisplay && aboveThreshold && ~plotHFframe
str = sprintf(' %0.2f, %0.2f, %0.2f (%0.2f)',A, mean(A));
h = text(xyz(iAtom,1),xyz(iAtom,2),xyz(iAtom,3),str,'Parent',hDisplay);
set(h,'Fontsize',16,'VerticalAl','bottom','Color',[0 0.6 0]);
end
if plotHFframe
hfarrowLength=0.4;
V = hfarrowLength*V;
dir1 = V(:,1);
dir2 = V(:,2);
dir3 = V(:,3);
Origin = thisdata.xyz(iAtom,:);

% principal directions
h = [];
h(1) = line(Origin(1)+[-1 1]*dir1(1),Origin(2)+[-1 1]*dir1(2),Origin(3)+[-1 1]*dir1(3),'Color','r','Parent',hDisplay);
h(2) = line(Origin(1)+[-1 1]*dir2(1),Origin(2)+[-1 1]*dir2(2),Origin(3)+[-1 1]*dir2(3),'Color',[0 0.5 0],'Parent',hDisplay);
h(3) = line(Origin(1)+[-1 1]*dir3(1),Origin(2)+[-1 1]*dir3(2),Origin(3)+[-1 1]*dir3(3),'Color','b','Parent',hDisplay);
set(h,'LineWidth',0.5);

% principal values
if hyperfineDisplay && aboveThreshold
format = ' %+0.2f';
h(1) = text(Origin(1)+dir1(1),Origin(2)+dir1(2),Origin(3)+dir1(3),sprintf(format,A(1)),'Color','r','Parent',hDisplay);
h(2) = text(Origin(1)+dir2(1),Origin(2)+dir2(2),Origin(3)+dir2(3),sprintf(format,A(2)),'Color',[0 0.5 0],'Parent',hDisplay);
h(3) = text(Origin(1)+dir3(1),Origin(2)+dir3(2),Origin(3)+dir3(3),sprintf(format,A(3)),'Color','b','Parent',hDisplay);
set(h,'FontSize',16);
end

% ellipsoids
N = 11;
r = abs(A);
r = r/max(r);
r = max(r,0.1)*hfarrowLength*1.8;
theta = linspace(0,pi,N);
phi = linspace(0,2*pi,2*N);
[theta,phi] = meshgrid(theta,phi);
xhf = r(1)*cos(phi).*sin(theta);
yhf = r(2)*sin(phi).*sin(theta);
zhf = r(3)*cos(theta);
vecs = V*[xhf(:) yhf(:) zhf(:)].';
xhf = reshape(vecs(1,:),2*N,[]);
yhf = reshape(vecs(2,:),2*N,[]);
zhf = reshape(vecs(3,:),2*N,[]);
c = sqrt(xhf.^2+yhf.^2+zhf.^2);
hs = surface(xhf+Origin(1),yhf+Origin(2),zhf+Origin(3),c,'Parent',hDisplay);
set(hs,'FaceColor','interp','Clipping','off');

end
I thought the modification would be as simple as changing the following line:
if hyperfineDisplay && aboveThreshold && ~plotHFframe
str = sprintf(' %0.2f, %0.2f, %0.2f (%0.2f)',A, mean(A));
h = text(xyz(iAtom,1),xyz(iAtom,2),xyz(iAtom,3),str,'Parent',hDisplay);
set(h,'Fontsize',16,'VerticalAl','bottom','Color',[0 0.6 0]);
To the new version:
if hyperfineDisplay && aboveThreshold && ~plotHFframe
str = sprintf('(%0.2f)',A, mean(A));
h = text(xyz(iAtom,1),xyz(iAtom,2),xyz(iAtom,3),str,'Parent',hDisplay);
set(h,'Fontsize',16,'VerticalAl','bottom','Color',[0 0.6 0]);
However now when I run the code I get a mismash of X,Y,Z over top of one another, some compilation error, or the need to have ellipsoids active (I am looking to have the only value on the image be the average A value over each H atom.

Thank you for any tips or advice,

GCH
Stefan Stoll
EasySpin Creator
Posts: 1053
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Orcaview; display only average A values

Post by Stefan Stoll »


str = sprintf('(%0.2f)',mean(A));


should do it.
Post Reply