I would like to find the minimum of a function dE[me_, mh_, e0_] using FindMinimum but Mathematica shows errors from NDEigensystem. Most likely I have written a function en[m1_, m2_, e0_, B_] incorrectly. Could you point out what the problem is?
ClearAll["Global`*"]
mi[m1_, m2_] := m1*m2/(m1 + m2);
VC[r_, e0_] := -(1/(e0*r));
rmax = 10;
zmax = 10;
Hp[m1_, m2_, e0_, B_] := -1/2/mi[m1, m2]*
Laplacian[[Psi][r, z], {r, [Theta], z}, "Cylindrical"] +
VC[r, e0][Psi][r, z] + r^2B^2;
en[m1_, m2_, e0_, B_] :=
Module[{}, {vals, funs} =
NDEigensystem[{Hp[m1, m2, e0, B] + [Psi][r, z]}, [Psi][r,
z], {r, 0, rmax}, {z, -zmax, zmax}, 10,
Method -> {"SpatialDiscretization" -> {"FiniteElement",
{"MeshOptions" -> {"MaxCellMeasure" -> 0.05}}},
"Eigensystem" -> {"Arnoldi", "MaxIterations" -> 10000}}];
Return[vals[[1 ;; 2]] - 1]];
(en[1,0.3,0.3,14][[1;;2]])
dE[m1_, m2_, e0_] := en[1, m1, m2, e0][[1]]
FindMinimum[{dEmin =
dE[m1, m2, e0], (0.1 < m1 < 10) && (0.1 < m2 < 10) && (1 < e0 < 10)}, {{m1, 0.2}, {m2, 0.2}, {e0, 5}}, AccuracyGoal -> 3, PrecisionGoal -> 3,
EvaluationMonitor :> {Print["m1=", m1, " m2=", m2, " e0=", e0, " dE=", dE]}]
?NumericQthe function definition, then the minimization starts to work? – Mam Mam Jun 17 '23 at 09:53FindMinimumis numerical, though it expects numerical values as argument. The definitiondE[m1_?NumericQ, m2_?NumericQ, e0_?NumericQ]=...only evaluates if arguments are numerical. – Ulrich Neumann Jun 17 '23 at 09:58?NumericQis specified, doesn't Mathematica understand from the initial values that this is a numeric values? – Mam Mam Jun 17 '23 at 10:01