【问题标题】:L-J Potential by ScilabScilab 的 L-J 电位
【发布时间】:2020-08-16 20:02:58
【问题描述】:

我实际上正在绘制 sigma=2.74 和 epsilon=0.0031 的 lj 电位曲线。下面是我的代码。

function [V,r]=lj(si,e)
     for i=1:3
            si=si*(1+(i-1)*0.1)
        r=linspace(0.75,8,1000)*si;
        V=4*e*((si./r).^12-(si./r).^6);
            subplot(2,2,1)
        plot((r/si),(V/e),'o')
            h = gca(); // get current axes
    h.data_bounds = [0.75, -2 ; 2.5, 2]
    end
    for i=1:3
            e=e*(1+(i-1)*0.3)
        r=linspace(0.75,8,1000)*si;
        V=4*e*((si./r).^12-(si./r).^6);
        subplot(2,2,2)
        plot((r/si),(V/e),'r')
        h = gca(); // get current axes
    h.data_bounds = [0.75, -2 ; 2.5, 2]
    end 
    endfunction

实际上,在上述情况下,我对不同的 sigma 和 epsilon 值进行了此操作,但我只得到一条曲线,在下面的代码中它运行良好(即,轴图仅在 x 和y 轴)。如果有人在我的第一个代码中进行了一些更改以获取各种价值,那就太好了。 下面是我的工作代码。

function [V,r]=lj(si,e)
    for i=1:3
        si=si*(1+(i-1)*0.1)
    r=linspace(0.75,8,1000);
    V=4*e*((si./r).^12-(si./r).^6);
        subplot(2,2,1)
    plot(r,V,'o')
        h = gca(); // get current axes
h.data_bounds = [2, -0.01 ; 6, 0.01]
end
    for i=1:3
        e=e*(1+(i-1)*0.3)
    r=linspace(0.75,8,1000);
    V=4*e*((si./r).^12-(si./r).^6);
    subplot(2,2,2)
    plot(r,V,'r')
    h = gca(); // get current axes
h.data_bounds = [2, -0.01 ; 6, 0.01]
end 
endfunction

【问题讨论】:

    标签: scilab computation-theory computation


    【解决方案1】:

    实际上,在您的第一个代码中,si./r 等于 1./linspace(0.75,8,1000) 并且不依赖于 i,对于 V 和 r/si 也是如此! 您只是绘制了 3 次相同的数据

    【讨论】:

    • 如果您对纠正代码发表评论并将其与代码进行比较,这样会更清楚。此外,对于您的回答,实际上因为 r 不如 si./ r 不依赖于 i,因为我知道这就是使用 for 循环的原因,因此对于 si 的每个新值,我们都会有新值。感谢您对此的讨论,并将澄清它
    猜你喜欢
    • 2015-01-14
    • 2020-09-14
    • 2020-05-18
    • 1970-01-01
    • 2022-06-28
    • 2019-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多