24小时热门版块排行榜    

查看: 220  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考博] 澳大利亚 Murdoch University 全奖博士招生(3个名额)地质化工冶金领域 +3 AI8RaGaPaSCR 2026-08-07 3/150 2026-08-13 14:15 by iu1c4A3rEPLS
[基金申请] 关于Filecode分析方法 +9 majunge000 2026-08-10 11/550 2026-08-13 10:40 by ZH远山
[基金申请] 我的国基提前知道中了,可是同事的操作让我实在接受不了,怎么会有这样的人 +9 家与远方 2026-08-10 14/700 2026-08-13 09:41 by 臭臭不臭01
[基金申请] 2019年青年基金涵评意见,大家看看几个A,几个B? +11 Tide man 2026-08-11 11/550 2026-08-13 07:35 by 撸猫猫
[基金申请] 好奇怪的filecode +5 布布和一二 2026-08-08 6/300 2026-08-12 16:11 by 云上清扬
[基金申请] filecode +13 documentary 2026-08-10 15/750 2026-08-12 15:56 by 云上清扬
[基金申请] 奇怪,两个人的filecode固定段从头到尾一模一样 +7 布布和一二 2026-08-10 10/500 2026-08-12 09:12 by 布布和一二
[基金申请] 综述论文作为代表作会不会影响评审专家的印象分? +11 yufeiwaner 2026-08-09 13/650 2026-08-12 08:17 by yufeiwaner
[硕博家园] 读博的好处 +3 lnee 2026-08-11 3/150 2026-08-11 18:10 by 希望我好好的
[基金申请] 什么时候出结果,有咨询渠道??? +3 Tide man 2026-08-11 3/150 2026-08-11 17:54 by kudofaye
[基金申请] 基金中了 +15 laoda193707 2026-08-06 15/750 2026-08-11 00:11 by jiafei2190
[基金申请] 确定了,国自然21号放榜 +6 布布和一二 2026-08-10 7/350 2026-08-10 19:15 by 2000zf36392
[基金申请] 国自然结果 +4 Vierhys 2026-08-10 8/400 2026-08-10 15:06 by Vierhys
[基金申请] 2026国自然放榜时间 +9 布布和一二 2026-08-08 9/450 2026-08-10 11:22 by xxxx2020
[基金申请] filecode与中标关系的预测 +5 布布和一二 2026-08-07 5/250 2026-08-09 16:15 by 袁向阳007
[基金申请] fileCode有新解读? +10 Tide man 2026-08-08 18/900 2026-08-09 12:55 by 仁砚薪传
[基金申请] 关于filecode,很负责任的告诉大家 +6 爱看书的可乐 2026-08-08 7/350 2026-08-08 22:13 by a_niu
[基金申请] 国基金的申报应该改成非等额制,评价高的钱多评价低的钱少,但是增加资助率 +7 a089 2026-08-07 7/350 2026-08-08 18:05 by gltch
[基金申请] 关于filecode +4 布布和一二 2026-08-07 7/350 2026-08-07 22:55 by zhanghaozhu
[基金申请] filecode变化情况 +6 布布和一二 2026-08-07 22/1100 2026-08-07 14:45 by 且听虎啸
信息提示
请填处理意见