Wanshan Li Physics 160 MATLAB program % Program ... - Google Sites

0 downloads 155 Views 7KB Size Report
Na = 1000; % number of oscillators in solid A (make it as large as you like). Nb = Na / 2; % number of oscillators in so
Wanshan Li Physics 160 MATLAB program % Program computes the multiplicities and entropies of a system of two Einstein solids, % one with Na number of oscillators and the other with Nb, sharing a total of q % units of energy under different macrostates. Na = 1000; % number of oscillators in solid A (make it as large as you like) Nb = Na / 2; % number of oscillators in solid B q = Na / 4; % total number of units of energy Qa = 0:1:q; % number of units of energy in solid A Qb = q:-1:0; % number of units of energy in solid B for i = 1:1:(q+1) % total of q+1 elements in vector Qa and Qb Ma(i) = nchoosek(Qa(i)+Na-1,Qa(i)); % Multiplicity of solid A Sa(i) = log(Ma(i)); % Entropy over k of solid A Mb(i) = nchoosek(Qb(i)+Nb-1,Qb(i)); % Multiplicity of solid B Sb(i) = log(Mb(i)); % Entropy over k of solid B M(i) = Ma(i) * Mb(i); % Multiplicity of the system S(i) = Sa(i) + Sb(i); % total Entropy over k of the system end % Plot entropies as functions of number of units of energy in solid A plot (Qa, Sa,Qa, Sb, Qa, S); Plot (with labels added manually)