level 3
lyw19961224
楼主
我觉得好像是Do循环哪里出错了,自己改了改好像还是不对,那个Do循环的机器精度是我加的,好像还是不对,希望有人帮我看看,指导一下,谢谢啦
ClearAll["`*"]
eq0[\[Mu]_] :=
1 - \[Omega]*
Sum[Sum[Exp[-(l/
t)*(1/2*\[Omega] - g*\[Sigma]*\[Omega] - \[Mu])]/(1 -
Exp[-l*x]), {l, 1, 1000}], {\[Sigma], {-0.5, 0.5}}];
g = 1;
\[Omega] = 0.5;
\[Beta] = 1/t;
a = 0.1;
x = \[Omega]/t;
K = M = {};
SetDirectory["D:\\chen\\"];
outfile = OpenAppend["Fermi M", PageWidth -> Infinity];
{\[Mu]i} = {-1};
Do[
{t = 5 - 0.005*nn;
{\[Mu]i} = {\[Mu]} = {\[Mu]} /.
FindRoot[{eq0[\[Mu]]}, {{\[Mu], \[Mu]i}}, AccuracyGoal -> 10,
PrecisionGoal -> 20];
N[M = t*
Sum[Sum[(-1)^(l + 1)/l*
Exp[-(l/t)*(1/2*\[Omega] - g*\[Sigma]*\[Omega] - \[Mu])]/(
1 - Exp[-l*x]), {l, 1, 1000}] +
x*(g*\[Sigma] - 1/2)*
Sum[(-1)^(l + 1)*
Exp[-(l/t)*(1/2*\[Omega] - g*\[Sigma]*\[Omega] - \[Mu])]/(
1 - Exp[-l*x]), {l, 1, 1000}] -
x*Sum[(-1)^(l + 1)*
Exp[-(l/
t)*(3/2*\[Omega] - g*\[Sigma]*\[Omega] - \[Mu])]/(1 -
Exp[-l*x])^2, {l, 1, 1000}], {\[Sigma], {-0.5,
0.5}}], $MachinePrecision];
K = AppendTo[K, {\[Beta], M}];
Block[{$RecursionLimit = 100}, G = AppendTo[G, {t, M}]];
Write[outfile, {\[Omega], g, \[Beta], t, \[Mu], M}];
Print[{\[Omega], g, \[Beta], t, \[Mu], M}]}, {nn, 0, 999}];
ListPlot[K, Joined -> True, AxesLabel -> {"\[Beta]", "M"},
PlotRange -> All]
ListPlot[G, Joined -> True, AxesLabel -> {"t", "M"}, PlotRange -> All]
Close[outfile];
General::munfl: 1.74125*10^-306/287 is too small to represent as a normalized machine number; precision may be lost.
General::munfl: 1/288 1.49796*10^-307 (-1) is too small to represent as a normalized machine number; precision may be lost.
General::munfl: Exp[-708.943] is too small to represent as a normalized machine number; precision may be lost.
General::stop: Further output of General::munfl will be suppressed during this calculation.
AppendTo::rvalue: G is not a variable with a value, so its value cannot be changed.
$RecursionLimit::reclim2: Recursion depth of 100 exceeded during evaluation of AppendTo[G,{5.,0.0144665}].
$RecursionLimit::reclim2: Recursion depth of 100 exceeded during evaluation of Append[Hold[AppendTo[G,{5.,0.0144665}]],{5.,0.0144665}].
2021年11月05日 02点11分
1
ClearAll["`*"]
eq0[\[Mu]_] :=
1 - \[Omega]*
Sum[Sum[Exp[-(l/
t)*(1/2*\[Omega] - g*\[Sigma]*\[Omega] - \[Mu])]/(1 -
Exp[-l*x]), {l, 1, 1000}], {\[Sigma], {-0.5, 0.5}}];
g = 1;
\[Omega] = 0.5;
\[Beta] = 1/t;
a = 0.1;
x = \[Omega]/t;
K = M = {};
SetDirectory["D:\\chen\\"];
outfile = OpenAppend["Fermi M", PageWidth -> Infinity];
{\[Mu]i} = {-1};
Do[
{t = 5 - 0.005*nn;
{\[Mu]i} = {\[Mu]} = {\[Mu]} /.
FindRoot[{eq0[\[Mu]]}, {{\[Mu], \[Mu]i}}, AccuracyGoal -> 10,
PrecisionGoal -> 20];
N[M = t*
Sum[Sum[(-1)^(l + 1)/l*
Exp[-(l/t)*(1/2*\[Omega] - g*\[Sigma]*\[Omega] - \[Mu])]/(
1 - Exp[-l*x]), {l, 1, 1000}] +
x*(g*\[Sigma] - 1/2)*
Sum[(-1)^(l + 1)*
Exp[-(l/t)*(1/2*\[Omega] - g*\[Sigma]*\[Omega] - \[Mu])]/(
1 - Exp[-l*x]), {l, 1, 1000}] -
x*Sum[(-1)^(l + 1)*
Exp[-(l/
t)*(3/2*\[Omega] - g*\[Sigma]*\[Omega] - \[Mu])]/(1 -
Exp[-l*x])^2, {l, 1, 1000}], {\[Sigma], {-0.5,
0.5}}], $MachinePrecision];
K = AppendTo[K, {\[Beta], M}];
Block[{$RecursionLimit = 100}, G = AppendTo[G, {t, M}]];
Write[outfile, {\[Omega], g, \[Beta], t, \[Mu], M}];
Print[{\[Omega], g, \[Beta], t, \[Mu], M}]}, {nn, 0, 999}];
ListPlot[K, Joined -> True, AxesLabel -> {"\[Beta]", "M"},
PlotRange -> All]
ListPlot[G, Joined -> True, AxesLabel -> {"t", "M"}, PlotRange -> All]
Close[outfile];
General::munfl: 1.74125*10^-306/287 is too small to represent as a normalized machine number; precision may be lost.
General::munfl: 1/288 1.49796*10^-307 (-1) is too small to represent as a normalized machine number; precision may be lost.
General::munfl: Exp[-708.943] is too small to represent as a normalized machine number; precision may be lost.
General::stop: Further output of General::munfl will be suppressed during this calculation.
AppendTo::rvalue: G is not a variable with a value, so its value cannot be changed.
$RecursionLimit::reclim2: Recursion depth of 100 exceeded during evaluation of AppendTo[G,{5.,0.0144665}].
$RecursionLimit::reclim2: Recursion depth of 100 exceeded during evaluation of Append[Hold[AppendTo[G,{5.,0.0144665}]],{5.,0.0144665}].