each value calculation for Mag Field
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Offroad Jeep
il 25 Mag 2015
Risposto: Walter Roberson
il 26 Mag 2015
Hi all, Kindly check this code. for each value of magnetic field there is value of angle alpha. I want to calculate zeeman energy and then for each angle alpha i want magnetization
clc
clear all
close all
nrows = 1;
si = (2.2 * 9.27e-24)* ones(nrows)
Si = sum(si); % Sum of rows for calculation of MAGNETIZATION
M_Si = sum(Si) % MAGNETIZATION ( Total magnetic moment of the array )
alpha = 30 * pi/180;% Initial angle of the magnetic moment with x-axis( No Field Applied )
beta = 20 * pi/180; % The angle at which Magnetic Field is applied to align all the moments
B_steps = 10;
applied_field = linspace(0,1,B_steps);
alpha_reduce = -linspace(alpha,beta,B_steps);
for i = 1:B_steps
alpha_trial = alpha + alpha_reduce(i)
zeeman(i) = - applied_field(i) * M_Si *cos(alpha_trial)
end
Magnetization = M_Si * cos(alpha_trial)
plot(applied_field,Magnetization,'*')
xlabel('Magnetization')
ylabel('applied_field')
0 Commenti
Risposta accettata
Walter Roberson
il 26 Mag 2015
At the end of your "for" loop, alpha_trial is going to be the last value it was in going through the loop, so it is going to be (alpha + alpha_reduce(B_steps)). Are you sure that is what you want?
Your code could be vectorized as
zeeman = -applied_field .* Msi .* cos(alpha + alpha_reduce);
But after your "for" loop, you do not use the value of zeeman(). So you might as well not calculate it at all.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Computational Fluid Dynamics (CFD) in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!