24小时热门版块排行榜    

查看: 241  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[论文投稿] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +7 YLsF7OSIoYU4 2026-11-21 7/350 2026-11-23 01:25 by TU1sx51gX99i
[硕博家园] 售SCI一区T0P文章,我:8.O.55.1.O.54,科目齐全,可+急 +6 YLsF7OSIoYU4 2026-11-21 6/300 2026-11-23 01:15 by AyQg4gRU5coM
[考研] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +4 Xoz0hXWi9tT1 2026-11-21 4/200 2026-11-23 01:14 by AyQg4gRU5coM
[论文投稿] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +7 Xoz0hXWi9tT1 2026-11-21 8/400 2026-11-23 01:04 by AyQg4gRU5coM
[考研] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +5 Xoz0hXWi9tT1 2026-11-21 8/400 2026-11-23 00:53 by AyQg4gRU5coM
[硕博家园] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +4 Xoz0hXWi9tT1 2026-11-21 5/250 2026-11-23 00:52 by AyQg4gRU5coM
[论文投稿] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +3 Xoz0hXWi9tT1 2026-11-21 3/150 2026-11-23 00:52 by AyQg4gRU5coM
[论文投稿] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 +3 Xoz0hXWi9tT1 2026-11-20 3/150 2026-11-23 00:41 by AyQg4gRU5coM
[硕博家园] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +5 Xoz0hXWi9tT1 2026-11-20 6/300 2026-11-23 00:31 by AyQg4gRU5coM
[教师之家] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 +3 TxdNP2oT1Q0A 2026-11-21 3/150 2026-11-22 20:27 by AyQg4gRU5coM
[公派出国] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +3 TxdNP2oT1Q0A 2026-11-21 3/150 2026-11-22 19:54 by EFrqTWPNvJJu
[考研] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +3 Gt0XhENGW3Q3 2026-11-21 3/150 2026-11-22 18:59 by 4xQThdVkmqn8
[基金申请] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +5 YpGmINmR5fp3 2026-11-21 6/300 2026-11-22 17:54 by 4xQThdVkmqn8
[硕博家园] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +5 YpGmINmR5fp3 2026-11-21 5/250 2026-11-22 17:53 by 4xQThdVkmqn8
[论文投稿] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +5 K2uSGhxsSAvH 2026-11-21 7/350 2026-11-22 17:10 by 4xQThdVkmqn8
[硕博家园] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +3 K2uSGhxsSAvH 2026-11-21 3/150 2026-11-22 17:09 by 4xQThdVkmqn8
[硕博家园] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +3 Gt0XhENGW3Q3 2026-11-21 4/200 2026-11-22 11:28 by HAlUgI97lcPc
[找工作] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +4 YpGmINmR5fp3 2026-11-21 5/250 2026-11-22 11:06 by HAlUgI97lcPc
[论文投稿] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 YpGmINmR5fp3 2026-11-21 3/150 2026-11-22 10:33 by HAlUgI97lcPc
[教师之家] 征友后感触 +7 重新启 2026-11-17 9/450 2026-11-20 17:06 by 爱唠叨的小木虫
信息提示
请填处理意见