Molecular Dynamics Monte Carlo Algoritm
조회 수: 1 (최근 30일)
이전 댓글 표시
So we have a single atom with a potential energy of E(x) = Kc*x^2 where x is the atom coordinate and kc=1 develop a monte carlo algorithm MC which computes the average energy at Temperature T from 0.1 to 1.0 increment of 0.1 and assuming Kb=1
Set maximum position displacement during MC move to dx=10. Also, set at each temperature the initial coordinate value x to 100. If MC code works correctly, then E ≈ T/2. The deviation of from the theoretical result T/2 should not exceed 10%. Present the results as a plot vs T and as a table.
Include in the table the number of MC steps performed to obtain at each T. Compute the acceptance rate at each temperature and investigate its dependence on temperature.
The code i developed so far can some one review it on the light of the question and add their feedback
if true
clc;clear
n=100;
x=rand(n,1);
gav=zeros(n,3);
gavvar=NaN(n,3);
gav(1,2)=x(1,1)^2;
for i=2:n
gav(i,2)=0.1*sum(x(1:i).^2)/i;
gavvar(i,2)=0.1*var(x(1:i).^2);
figure(1);
plot(gav(:,2));
hold on
figure(2)
plot(gavvar(:,2));
grid on
end
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!