From 057b51a0ab19b9c35032681104540f721f36a192 Mon Sep 17 00:00:00 2001 From: Laura Nervo <lnervo@esrf.fr> Date: Mon, 14 May 2012 09:41:31 +0000 Subject: [PATCH] Crystallography : - add to gtReadSpaceGroup the crystal_system info - adapt gtSetup code - remove from gtCalculateDist the crystal_system calculation Signed-off-by: Laura Nervo <laura.nervo@esrf.fr> git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@406 4c865b51-4357-4376-afb4-474e03ccb993 --- 1_preprocessing/gtSetup.m | 17 ++++++---- zUtil_Cryst/gtCalculateDist.m | 47 +++++++++++--------------- zUtil_Cryst/gtReadSpaceGroup.m | 62 +++++++++++++++++++++++++++------- 3 files changed, 79 insertions(+), 47 deletions(-) diff --git a/1_preprocessing/gtSetup.m b/1_preprocessing/gtSetup.m index c403776c..25b1500c 100644 --- a/1_preprocessing/gtSetup.m +++ b/1_preprocessing/gtSetup.m @@ -2,6 +2,10 @@ function gtSetup() % GTSETUP Sets up the parameters file for the experiment % gtSetup() % --------- +% +% Version 011 14-05-2012 by LNervo +% Modify gtReadSpaceGroup to give lattice and crystal systems +% % Version 010.1 03-05-2012 by LNervo % Add lab2sam and sam2lab definition in samgeo % @@ -342,13 +346,12 @@ for ii = 1 : parameters.acq.nof_phases parameters.cryst(ii) = gtAddMatFile(parameters.cryst(ii),cif,true,true,false); clear cif - [lattice,~] = gtReadSpaceGroup(parameters.cryst(ii).spacegroup); - if isempty(lattice) - parameters.cryst(ii).lattice_system = parameters.cryst(ii).crystal_system; - else - parameters.cryst(ii).lattice_system = lattice; - end - clear lattice + % crystal_system should be read from .cif file + % it is overwritten here + [lattice_system, crystal_system, ~] = gtReadSpaceGroup(parameters.cryst(ii).spacegroup); + parameters.cryst(ii).lattice_system = lattice_system; + parameters.cryst(ii).crystal_system = crystal_system; + clear lattice_system crystal_system disp('Saving parameters.mat in the analysis directory...') save(parameters_name,'parameters'); diff --git a/zUtil_Cryst/gtCalculateDist.m b/zUtil_Cryst/gtCalculateDist.m index 86f894a8..b46d1a29 100644 --- a/zUtil_Cryst/gtCalculateDist.m +++ b/zUtil_Cryst/gtCalculateDist.m @@ -1,11 +1,10 @@ -function [dsp,twotheta,crystal_system] = gtCalculateDist(hkl,cryst,energy) +function [dsp,twotheta] = gtCalculateDist(hkl,cryst,energy) -% GTCALCULATEDIST Calculates d-spacing and twice the Bragg angle for a -% given hkl. Also gives crystal and lattice system of the spacegroup. -% [dsp,twotheta,crystal_system] = gtCalculateDist(hkl,cryst,energy) -% ----------------------------------------------------------------- +% GTCALCULATEDIST Calculates d-spacing and twice the Bragg angle for a given hkl +% [dsp,twotheta] = gtCalculateDist(hkl,cryst,energy) +% -------------------------------------------------- % -% INPUT +% INPUT: % hkl - row vector of Miller indices; % size 1x3 or 1x4 for hexagonal % cryst.latticepar - lattice parameters @@ -13,14 +12,15 @@ function [dsp,twotheta,crystal_system] = gtCalculateDist(hkl,cryst,energy) % cryst.hermann_mauguin - Hermann-Mauguin symbol % energy - beam energy in keV % -% OUTPUT +% OUTPUT: % dsp - d-spacing of the specified hkl family % twotheta - twice the Bragg angle of the specified hkl family -% crystal_system - crystallographic crystal system of the specified -% spacegroup % +% Version 005 14-05-2012 by LNervo +% Remove crystal_system calculation +% % Version 004 14-03-2012 by PReischig -% Addition of lattice system as output; formatting. +% formatting. % % Version 003 08-03-2012 by PReischig % Seperated 'parameters' input into 'cryst' and 'energy'. @@ -69,8 +69,7 @@ end % Spacegroups -if between(spacegroup,1,2) - crystal = 'triclinic'; % a ~= b ~= c; alpha ~= beta ~= gamma ~= 90 +if between(spacegroup,1,2) % crystal_system = 'triclinic'; % a ~= b ~= c; alpha ~= beta ~= gamma ~= 90 Y = h^2/a^2*(sind(alpha))^2 + k^2/b^2*(sind(beta))^2 + l^2/c^2*(sind(gamma))^2; Z = 2*k*l/b/c*(cosd(beta) *cosd(gamma) - cosd(alpha)) + ... @@ -81,34 +80,30 @@ if between(spacegroup,1,2) 2*cosd(alpha)*cosd(beta)*cosd(gamma))*(Y+Z); end -if between(spacegroup,3,15) - crystal = 'monoclinic'; % a ~= b ~= c; alpha = gamma = 90 ~= beta +if between(spacegroup,3,15) % crystal_system = 'monoclinic'; % a ~= b ~= c; alpha = gamma = 90 ~= beta invdsp2 = h^2/(a*sind(beta))^2 + k^2/b^2 + l^2/(c*sind(beta))^2 - ... (2*h*l*cosd(beta)) / (a*c*(sind(beta))^2); end -if between(spacegroup,16,74) - crystal = 'orthorhombic'; % a ~= b ~= c; alpha = beta = gamma = 90 +if between(spacegroup,16,74) % crystal_system = 'orthorhombic'; % a ~= b ~= c; alpha = beta = gamma = 90 invdsp2 = h^2/a^2 + k^2/b^2 + l^2/c^2; end -if between(spacegroup,75,142) - crystal = 'tetragonal'; % a = b ~= c; alpha = beta = gamma = 90 +if between(spacegroup,75,142) % crystal_system = 'tetragonal'; % a = b ~= c; alpha = beta = gamma = 90 invdsp2=(h^2+k^2)/a^2+l^2/c^2; end -if between(spacegroup,143,167) - crystal = 'trigonal'; +if between(spacegroup,143,167) % crystal_system = 'trigonal'; - if ~isempty(strfind(hermann,'P')) % hexagonal lattice + if ~isempty(strfind(hermann,'P')) % hexagonal lattice_system % a1 = a2 = a3 ~= c; alpha = beta = 90; gamma = 120 invdsp2 = 4/(3*a^2) * (h^2 + k^2 + h*k) + l^2/c^2; - elseif ~isempty(strfind(hermann,'R')) % rhombohedral lattice + elseif ~isempty(strfind(hermann,'R')) % rhombohedral lattice_system % a = b = c; alpha = beta = gamma ~= 90 Y1 = h^2 + k^2 + h*k; @@ -121,14 +116,12 @@ if between(spacegroup,143,167) end end -if between(spacegroup,168,194) || spacegroup==663 % snow case - crystal = 'hexagonal'; % a1 = a2 = a3 ~= c; alpha = beta = 90; gamma = 120 +if between(spacegroup,168,194) || spacegroup==663 % crystal_system = 'hexagonal'; % a1 = a2 = a3 ~= c; alpha = beta = 90; gamma = 120 invdsp2 = 4/(3*a^2)*(h^2 + k^2 + h*k) + l^2/c^2; end -if between(spacegroup,195,230) - crystal = 'cubic'; % a = b = c; alpha = beta = gamma = 90 +if between(spacegroup,195,230) % crystal_system = 'cubic'; % a = b = c; alpha = beta = gamma = 90 invdsp2 = (h^2+k^2+l^2)/a^2; end @@ -140,6 +133,4 @@ dsp = 1/(invdsp2)^0.5; % 2theta twotheta = 2*asind(lambda/(2*dsp)); -crystal_system = crystal; - end % end of function diff --git a/zUtil_Cryst/gtReadSpaceGroup.m b/zUtil_Cryst/gtReadSpaceGroup.m index ad8d8592..3854db04 100644 --- a/zUtil_Cryst/gtReadSpaceGroup.m +++ b/zUtil_Cryst/gtReadSpaceGroup.m @@ -1,17 +1,20 @@ -function [lattice,table]=gtReadSpaceGroup(sg) +function [lattice, crystal, table] = gtReadSpaceGroup(sg) % GTREADSPACEGROUP Read the spacegroup and give the hermann_mauguin symbol -% [lattice,table]=gtReadSpaceGroup(sg) -% ------------------------------------ +% [lattice, crystal, table] = gtReadSpaceGroup(sg) +% ------------------------------------------------ % % INPUT: % sg = spacegroup to look at <double> % % OUTPUT: % lattice = lattice system for this spacegroup -% table = mhashtable with spacegroup,hermann_mauguin -% +% crystal = crystal system for this spacegroup +% table = mhashtable with 'spacegroup' : hermann_mauguin symbol +% +% Version 003 14-05-2012 by LNervo +% Add lattice system calculation -fid=fopen('spacegroups.dat','r'); +fid=fopen( fullfile( getenv('USER'), 'matlabDCT', 'zUtil_Cryst','spacegroups.dat' ),'r'); C=textscan(fid,'%s %d','delimiter','\t','commentstyle','matlab'); fclose(fid); @@ -29,15 +32,50 @@ end table.remove('0'); herm=table.get(num2str(sg)); -if between(sg,143,167) - if ~isempty(strfind(herm,'P')) % hexagonal lattice - lattice = 'hexagonal'; % a1 = a2 = a3 ~= c; alpha = beta = 90; gamma = 120 +% Spacegroups + +if between(sg,1,2) + crystal = 'triclinic'; % a ~= b ~= c; alpha ~= beta ~= gamma ~= 90 + lattice = 'triclinic'; +end + +if between(sg,3,15) + crystal = 'monoclinic'; % a ~= b ~= c; alpha = gamma = 90 ~= beta + lattice = 'monoclinic'; +end + +if between(sg,16,74) + crystal = 'orthorhombic'; % a ~= b ~= c; alpha = beta = gamma = 90 + lattice = 'orthorhombic'; +end + +if between(sg,75,142) + crystal = 'tetragonal'; % a = b ~= c; alpha = beta = gamma = 90 + lattice = 'tetragonal'; +end + +if between(sg,143,167) + crystal = 'trigonal'; + + if ~isempty(strfind(herm,'P')) % hexagonal lattice + % a1 = a2 = a3 ~= c; alpha = beta = 90; gamma = 120 + lattice = 'hexagonal'; elseif ~isempty(strfind(herm,'R')) % rhombohedral lattice - lattice = 'rhombohedral'; % a = b = c; alpha = beta = gamma ~= 90 + % a = b = c; alpha = beta = gamma ~= 90 + lattice = 'rhombohedral'; end -else - lattice =''; end + +if between(sg,168,194) || sg==663 % snow case + crystal = 'hexagonal'; % a1 = a2 = a3 ~= c; alpha = beta = 90; gamma = 120 + lattice = 'hexagonal'; +end + +if between(sg,195,230) + crystal = 'cubic'; % a = b = c; alpha = beta = gamma = 90 + lattice = 'cubic'; +end + end % end of function \ No newline at end of file -- GitLab