Dividing arrays by sets

2 Ansichten (letzte 30 Tage)
Sam Vellequette
Sam Vellequette am 8 Apr. 2024
Beantwortet: Avadhoot am 16 Apr. 2024
Hello there,
The below table determines the multiplicity factor of some (hkl) plane in X-Ray diffraction. h, k, and l are all whole numbers typically ranging from 0 to 10, and the three give a plane within a crystal. Exs: (1 0 0) plane, (2 1 1), etc. Sorry for the exposition, but the reasoning is because the table below gives the multiplicity factors for sets of planes within different crystal systems. I am trying to find a way to tell, given some random 1x3 array [h k l], which one of these factors I should use, without using 500 if statements.
Further complexity comes from the fact that the order of (hkl) matter in non-cubic systems due to the lesser symmetries of the unit cells. I'm a programming novice, and don't know if there's some useful functions of something like set theory or graph theory etc. that would let me evaluated this easily. Any and all advice is deeply appreciated!

Antworten (1)

Avadhoot
Avadhoot am 16 Apr. 2024
I understand that you want to write a function for finding the multiplicity factor given a 1x3 array of the h,k,l values for the planes. As per the table you have provided, there are a lot of different cases. This can be accomplished using a switch case instead of if statements. You can refer to the below code for a blueprint on how to implement it.
function multiplicity = getMultiplicitySwitch(hkl, crystalSystem)
% Determines the multiplicity based on the crystal system using switch case
switch crystalSystem
case 'cubic'
multiplicity = getCubicMultiplicity(hkl);
% Add other cases for different crystal systems
otherwise
error('Unknown crystal system');
end
end
function multiplicity = getCubicMultiplicity(hkl)
% Example function for cubic system multiplicity determination
h = hkl(1);
k = hkl(2);
l = hkl(3);
% Implement the actual rules for your system
end
% Example usage
hkl = [1, 0, 0];
crystalSystem = 'cubic';
multiplicity = getMultiplicitySwitch(hkl, crystalSystem);
fprintf('Multiplicity for [%d %d %d] in %s system: %d\n', hkl, crystalSystem, multiplicity);
Also there is a simpler formula to calculate the multiplicity in case of cubic systems. It is as follows:
Here m is the multiplicity, N is the number of zeros present in the [h,k,l] vector and n is the number of repeated values including 0.
This formula has origins in group theory. You can find similar formulae for other cases to simplify your calculations.
You can find details about the above formula on the following link: https://physics.stackexchange.com/questions/523836/equation-for-the-multiplicity-of-a-set-of-planes
I hope this helps.

Kategorien

Mehr zu Crystals finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by