24小时热门版块排行榜    

查看: 182  |  回复: 0

chrislan625

新虫 (小有名气)

[求助] 请教一个用门特卡罗计算合金二维面上原子排列随机度的问题

有大概的框架 可是6个地方的代码不太会写


function [ config ] = alloy( nBox, fAlloy, nSweeps, T, Eam )
%ALLOY Performs Metropolis Monte Carlo of a lattice gas model of an alloy
%   A random alloy is represented as a 2 dimensional lattice gas in which
%   alloying atoms can exchange position with matrix atoms using the
%   Metropolis alogorithm. The purpose is to show how alloys become more
%   random as the temperature increases.
%
%   Input arguments
%       nBox    The size of the 2-D grid
%       fAlloy  The fraction of sites occupied by alloying atoms
%       nSweeps The number of Monte Carlo moves
%       T       The temperature (K)
%       Eam     Alloy-matrix interaction energy (eV)
%
%   Output arguments
%       config  The final configuration
%
% Set interactions between like atoms to zero
% Eaa     Alloy-alloy interaction energy (eV)
% Emm     Matrix-matrix interaction energy (eV)
%
Emm = 0.0;
Eaa = 0.0;
%
% Compute kT in eV
%
kB = 8.617332e-5;
kT = kB*T;
%
% Initialize the configuartion
%   1   Matrix atoms
%   2   Alloy atoms
%

%%% PUT CODE HERE

%
% Set up energy matrix
%
Ematrix(1,1) = Emm;
Ematrix(1,2) = Eam;
Ematrix(2,1) = Eam;
Ematrix(2,2) = Eaa;
%
% Carry out the random swaps
%

%%% PUT CODE HERE

%
% Plot the configuration. Put extra zeros around border so pcolor works
% properly.
%
config_plot = zeros(nBox+1);
config_plot(1:nBox, 1:nBox) = config;
pcolor(config_plot);
end

function [ixb iyb dE] = swapInfo(ixa, iya, dab, nBox, config, Ematrix)
%SWAPINFO Returns the position of the neighbour and the energy change
%   following a swap
%
%   Input arguments
%       ixa         X coordinate of first atom
%       iya         Y coordinate of first atom
%       dab         Direction of second atom relative to first. There are four
%                   possible directions, so this takes values between 1 and
%                   4. Together with ixa and ixb, this allows the position
%                   of the second atom to be computed. This calculation is
%                   done by getNeighbour
%       config      The configuration of alloy atoms
%       nBox        System size
%       Ematrix     The 2x2 matrix of bond energies
%   Output arguments
%       ixb         X coordinate of second atom
%       iyb         Y coordinate of second atom
%       dE          Energy change following swap
%
% Find neighbour atom
%

%%% PUT CODE HERE

%
% Find energy change
%

%%% PUT CODE HERE

%
    function [ix2 iy2] = getNeighbour (ix1, iy1, d12)
        %GETNEIGHBOUR returns the position of a neighbouring atom
        %
        % Input arguments
        %   ix1     X coordinate of first atom
        %   iy1     Y coordinate of first atom
        %   d12     Direction of second atom relative to first
        % Output arguments
        %   ix2     X coordinate of second atom
        %   iy2     Y coordinate of second atom
        %
        % Find new x coordinate
        %

%%% PUT CODE HERE

        %
        % Find new y coordinate
        %

%%% PUT CODE HERE

    end
end
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 chrislan625 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 0703化学调剂 ,六级已过,有科研经历 +11 曦熙兮 2026-03-15 11/550 2026-03-19 17:13 by yywzz
[考研] 本人考085602 化学工程 专硕 +17 不知道叫什么! 2026-03-15 19/950 2026-03-19 15:06 by 尽舜尧1
[考研] 304求调剂 +3 曼殊2266 2026-03-18 3/150 2026-03-19 14:42 by peike
[考研] 化学求调剂 +3 临泽境llllll 2026-03-17 4/200 2026-03-19 13:59 by houyaoxu
[考研] 求材料调剂 +10 隔壁陈先生 2026-03-12 10/500 2026-03-19 09:15 by 无际的草原
[考研] 0703化学调剂 +8 妮妮ninicgb 2026-03-15 12/600 2026-03-19 05:55 by anny19840123
[考研] 材料工程专硕调剂 +5 204818@lcx 2026-03-17 6/300 2026-03-18 22:55 by 204818@lcx
[考研] 330求调剂 +3 小材化本科 2026-03-18 3/150 2026-03-18 21:55 by 无懈可击111
[考研] 材料专硕306英一数二 +10 z1z2z3879 2026-03-16 13/650 2026-03-18 14:20 by 007_lilei
[考研] 265求调剂 +3 梁梁校校 2026-03-17 3/150 2026-03-18 09:12 by zhukairuo
[硕博家园] 湖北工业大学 生命科学与健康学院-课题组招收2026级食品/生物方向硕士 +3 1喜春8 2026-03-17 5/250 2026-03-17 17:18 by ber川cool子
[考研] 302求调剂 +4 小贾同学123 2026-03-15 8/400 2026-03-17 10:33 by 小贾同学123
[考研] 机械专硕325,寻找调剂院校 +3 y9999 2026-03-15 5/250 2026-03-16 19:58 by y9999
[考研] 333求调剂 +3 文思客 2026-03-16 7/350 2026-03-16 18:21 by 文思客
[考研] 0854控制工程 359求调剂 可跨专业 +3 626776879 2026-03-14 9/450 2026-03-16 17:42 by 626776879
[基金申请] 今年的国基金是打分制吗? 50+3 zhanghaozhu 2026-03-14 3/150 2026-03-16 17:07 by 北京莱茵润色
[考研] 304求调剂 +3 曼殊2266 2026-03-14 3/150 2026-03-16 16:39 by houyaoxu
[考研] 080500,材料学硕302分求调剂学校 +4 初识可乐 2026-03-14 5/250 2026-03-14 21:08 by peike
[考研] 中科大材料专硕319求调剂 +3 孟鑫材料 2026-03-13 3/150 2026-03-14 18:10 by houyaoxu
[考研] 081200-11408-276学硕求调剂 +3 崔wj 2026-03-12 4/200 2026-03-12 19:33 by 求调剂zz
信息提示
请填处理意见