I have an experimental cyclic curve which looks like this:

datajapanUpper = {{3.22, 0.0149}, {4.7457, 0.06081}, {6.053,
0.1276}, {7.143, 0.211}, {7.9418, 0.3112}, {8.523, 0.411}, {9.322,
0.515}, {9.975, 0.624}, {10.847, 0.736}, {11.50, 0.84}, {12.445,
0.937}, {13.825, 0.94}, {14.48, 0.837}, {14.99, 0.711}, {15.20,
0.587}, {15.57, 0.46}, {16.00, 0.336}, {16.44, 0.211}, {17.167,
0.0984}}
datajapanLower = {{11.937, -0.031}, {10.629, -0.0853}, {9.467, -0.17}, \
{8.596, -0.26}, {7.869, -0.356}, {7.2154, -0.469}, {6.489, -0.594}, \
{5.835, -0.7197}, {5.036, -0.836}, {4.237, -0.94}, {3.365, -1.02}, \
{2.058, -0.96}, {1.404, -0.8448}, {0.968, -0.719}, {0.75, -0.595}, \
{0.46, -0.469}, {0.388, -0.302}, {0.315, -0.177}, {-0.121, -0.052}}
It is current/potential curve (x axis is Electrode potential, y axis is current). As you can see, I change Electrode potential from around 19 to around zero and then change it back from zero to 19. and I measure current, while Electrode potential is being changed. I divided this one experimental curve into two parts: Lower part and Upper part. Just because I think it is convenient. Lower part starts at start-point and ends at turn-around point. Upper part starts at turn-around point and ends at start point. This blue-dot curve may look like non-cyclic just because I have choosen some experimental points (not all of them). The real curve looks approximately like thin-red line, so it is actually cyclic, and it starts and ends at one point. I should fit this curve with a model:
EquationForFilmPotentialLowerPart =
ParametricNDSolve[{y'[x] == (kf*(1 - 0.02*ka*Exp[y[x]])*Exp[0.5*(x - y[x])]-
kf*0.02*ka*Exp[y[x]]*Exp[0.5*(y[x] - x)])/(-10^(-9)*ka*
Exp[y[x]]), y[19] == 3.9 + Log[1/ka]},
y, {x, -8, 21}, {ka, kf}]
Where y[x] is Film Potential. x is Electrode potential. Expression for Current:
CurrentLowerPart = -(0.130)*ka*Exp[y[ka, kf][x]]*y[ka, kf]'[x] /.
EquationForFilmPotentialLowerPart
So, I have initial condition for lower part y[19] = 3.9+Log[1/ka] at start point, i have equations for film potential of lower part and for current of lower part. I also have equation for Film potential of upper part:
EquationForFilmPotentialUpperPart =
ParametricNDSolve[{y'[
x] == (kf*(1 - 0.02*ka*Exp[y[x]])*Exp[0.5*(x - y[x])] -
kf*0.02*ka*Exp[y[x]]*Exp[0.5*(y[x] - x)])/(-10^(-9)*ka*
Exp[y[x]]), y[19] == here should be an initial condition for upper part},
y, {x, -8, 21}, {ka, kf}]
and for current of upper part, but I don't have initial condition for upper part:
CurrentUpperPart = (0.130)*ka*Exp[y[ka, kf][x]]*y[ka, kf]'[x] /.
EquationForFilmPotentialUpperPart
Initial condition for film potential of upper part should be equal to end-point y[x] of film potential of lower part. I mean, I solve EquationForFilmPotentialLowerPart by parametric NDSOlve and the last point of this solution (x=0, y=???) should be the initial condition for EquationForFilmPotentialUpperPart
If it is not clear enough, I show the way I do it myself... I take random values of parameters ka, kf. (For example ka=0.025, kf=0.0000000031). I solve EquationForFilmPotentialLowerPart with NDSolve for these particular values of parameters (eqLower = EquationForFilmPotentialLowerPart with ka = 0.025 and kf = 0.0000000031):
eqLower = NDSolve[{y'[
x] == (0.00000000311*(1 - 0.02*0.025*Exp[y[x]])*
Exp[0.5*(x - y[x])] -
0.00000000311*0.02*0.025*Exp[y[x]]*
Exp[0.5*(y[x] - x)])/(-10^(-9)*0.025*Exp[y[x]]),
y[19] == 3.9 + Log[1/0.025]}, y, {x, 0, 19}]
Then, I Plot this curve y[x] and use "get coordinate" to take end point
Then I use end-point as initial condition for eqUpper (eqUpper equals to EquationForFilmPotentialUpperPart with ka=0.025, kf=0.0000000031):
eqUpper =
NDSolve[{y'[
x] == (0.00000000311*(1 - 0.02*0.025*Exp[y[x]])*
Exp[0.5*(x - y[x])] -
0.00000000311*0.02*0.025*Exp[y[x]]*
Exp[0.5*(y[x] - x)])/(10^(-9)*0.025*Exp[y[x]]),
y[0] == 5.014}, y, {x, 0, 19}]
then I Plot current and experimental data together:
Show[{Plot[-(0.130)*0.025*Exp[y[x]]*y'[x] /. eqLower, {x, 0, 19}],
Plot[(0.130)*0.025*Exp[y[x]]*y'[x] /. eqUpper, {x, 0, 19}],
ListPlot[datajapanUpper], ListPlot[datajapanLower]}]
And I see, ooh, lower part looks rather good, but upper part looks bad, so I change values of ka and kf and try again. til I get sort of "good" fit.
The Question is how to make mathematica fit cyclic curve?




2)This question is more detailed and more specific. this question is in particular abot how to fit one cyclic curve with two differential equations simultaneously, moreover, the and-point of first differential equation represents initial condition for second differential equation. moreover, dif.eqs have different directions. .
– D.Anishchenko May 13 '16 at 17:15NDSolve, knowledgeable about fitting, and in particular knowledgeable about both. There have been only a couple of people who have been active in giving answers to multiple such questions, and neither has been active lately. If you give a simpler toy example, you might get some help. – Michael E2 May 14 '16 at 12:00