24小时热门版块排行榜    

CyRhmU.jpeg
查看: 1669  |  回复: 9

zhangluyoa

银虫 (初入文坛)

[求助] 求解扩散方程问题

有一个方程如图
源码是
function AA
D0=3.55e-19;
options=optimset('tolx',1e-9);
[D,resnorm,residual,exitflag,output,lambda,jacobian] = lsqnonlin(@fei,D0,[],[],options)

function F=fei(D)
C0=0.687;
d=0.02;
Ceq=20;
t=60;
C=4.136;
m=1-(C0-C)/(C0-Ceq);
s=[];
k=0:1000;
s=sum(8./(pi*(2*k+1)).^2.*exp(-D*(pi*(2*k+1)).^2*t*60/(d^2)));
s
F=sum((m-s').^2);


而得到的结果怎么也不对 如下
得到的D值怎么都是跟赋的D0值是一样的额
s =

    0.9998


s =

    0.2158


s =

   Inf


s =

    0.2447


s =

   Inf


s =

    0.2161

Optimization terminated: norm of the current step is less
than OPTIONS.TolX.

D =

  3.5500e-019


resnorm =

    0.0010


residual =

    0.0318


exitflag =

     2


output =

    firstorderopt: 7.1546e+005
       iterations: 2
        funcCount: 6
     cgiterations: 1
        algorithm: 'large-scale: trust-region reflective Newton'
          message: [1x77 char]


lambda =

    lower: 0
    upper: 0


jacobian =

   (1,1)     2.2480e+007
到底怎么弄得,小弟是菜鸟,希望有高手跟好心人帮我5555
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

ya634984094

铜虫 (小有名气)

感谢参与,应助指数 +1
臭水沟: 应助指数-1, 非应助贴请不要选择“应助回帖”~ 2012-04-03 14:47:18
你这是用uds编的输出吗??
2楼2012-04-03 10:54:59
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zhangluyoa

银虫 (初入文坛)

引用回帖:
2楼: Originally posted by ya634984094 at 2012-04-03 10:54:59:
你这是用uds编的输出吗??

什么是ubs啊,用的是matlab,我是菜鸟
3楼2012-04-03 11:35:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

ya634984094

铜虫 (小有名气)

【答案】应助回帖


臭水沟: 金币+1, 谢谢交流~~ 2012-04-04 11:15:14
引用回帖:
3楼: Originally posted by zhangluyoa at 2012-04-03 11:35:39:
什么是ubs啊,用的是matlab,我是菜鸟

呃~~matlab我不是很熟,uds是fluent用来求解方程的~~
4楼2012-04-03 12:34:11
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zhangluyoa

银虫 (初入文坛)

我就是想求D值,但是不知道为什么给赋D0值是一样的
5楼2012-04-03 14:58:46
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
臭水沟: 金币+3, 谢谢交流~~ 2012-04-04 11:15:22
zhangluyoa: 金币+4, 有帮助 2012-04-11 16:35:41
CODE:
D0=3.55e-6;
options=optimset('tolx',1e-9);
[D,resnorm,residual,exitflag,output,lambda,jacobian] = lsqnonlin(@fei,D0,[],[],options)

function F=fei(D)
C0=0.687;
d=0.02;
Ceq=20;
t=60;
C=4.136;
m=1-(C0-C)/(C0-Ceq);
s=[];
k=0:5000;
s=sum(8./(pi*(2*k+1)).^2.*exp(-D*(pi*(2*k+1)).^2[color=red]*t[/color]/(d^2)));
F=sum((m-s').^2);

Local minimum possible.

lsqnonlin stopped because the final change in the sum of squares relative to
its initial value is less than the default value of the function tolerance.




D =

  5.0774e-008


resnorm =

  1.1370e-007


residual =

  3.3720e-004


exitflag =

     3


output =

    firstorderopt: 39.0251
       iterations: 13
        funcCount: 28
     cgiterations: 0
        algorithm: 'large-scale: trust-region reflective Newton'
          message: [1x458 char]


lambda =

    lower: 0
    upper: 0


jacobian =

   (1,1)     1.1573e+005
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
6楼2012-04-03 17:56:51
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

★ ★ ★
臭水沟: 金币+1, 谢谢交流~~ 2012-04-04 11:15:29
zhangluyoa: 金币+2, 有帮助 2012-04-11 16:35:57
s=sum(8./(pi*(2*k+1)).^2.*exp(-D*(pi*(2*k+1)).^2*t*60/(d^2))); 多乘了60?
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
7楼2012-04-03 17:58:17
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zhangluyoa

银虫 (初入文坛)

引用回帖:
7楼: Originally posted by dbb627 at 2012-04-03 17:58:17:
s=sum(8./(pi*(2*k+1)).^2.*exp(-D*(pi*(2*k+1)).^2*t*60/(d^2))); 多乘了60?

不是,t是分钟,乘以60变成秒
8楼2012-04-04 19:08:11
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

luyao_zhang

银虫 (初入文坛)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★
zhangluyoa: 金币+44, ★★★★★最佳答案, 终于解决了 2013-07-16 17:35:01
xiegangmai: 金币+2, 谢谢参与! 2013-07-24 21:03:08
精度太小,已经小于计算机优化精度,所以优化计算停止,把D 增大10^8倍,方程中减小10^8倍,可顺利求解

D0=3.55;

[D,resnorm,residual,exitflag,output,lambda,jacobian] = lsqnonlin(@fei,D0,[],[])

function F=fei(D)
C0=0.687;
d=0.02;
Ceq=20;
t=60;
C=4.136;
m=1-(C0-C)/(C0-Ceq);
s=[];
k=0:1000;
s=sum(8./(pi*(2*k+1)).^2.*exp(-D*0.00000001*(pi*(2*k+1)).^2*t*60/(d^2)));
s
F=sum((m-s').^2);




结果
D =

   0.04933156266209


resnorm =

    1.200260299201833e-008

D就等于4.93e-10
热爱痛苦
9楼2013-07-16 17:34:30
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

1657956529

新虫 (初入文坛)

这是解的什么方程,我也想救助一下,fick第二定律怎么求解方程
10楼2016-11-22 18:58:42
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 zhangluyoa 的主题更新
信息提示
请填处理意见