# Get three plots and manipulate some variables of the respective equations?

Posted 1 month ago
255 Views
|
4 Replies
|
0 Total Likes
|
 Hello all, I'm writing a code from the which I desire to get three plots and manipulate some variables of the respective equations. Two of the three plots work, however, the last one doesn't show up and Mathematica doesn't follow my instructions of the ranges I tell the program to plot. It plots another variable and other ranges. Also, the program doesn't identify any error. I've been checking all the equations but everything seems to be fine. I don't know what else can I do. Please, help with this issue. The code is attached.Thanks. Attachments:
Answer
4 Replies
Sort By:
Posted 1 month ago
 You might want to try something like: ClearAll["Global*"] Manipulate[ Grid[ {{ Plot[\[Phi][x, c0, \[Phi]2, x2], {x, 0, 10}, PlotRange -> {0, 0.3}, FrameLabel -> {Row[{Style["x", Italic], "[nm]"}], Row[{Style["Potential", Italic], "(mV)"}]}, PlotLabel -> Row[{"Potential profile of a monovalent salt"}], PlotStyle -> {Thick, Blue}, Frame -> True, PerformanceGoal -> "Quality", ImageSize -> 280 ], Plot[cf[x, c0, \[Phi]2, x2], {x, 0, 0.5}, PlotRange -> All, FrameLabel -> {Row[{Style["x", Italic], "[nm]"}], Row[{Style["Concentration", Italic], "(M)"}]}, PlotLabel -> Row[{"Concentration profile of a monovalent salt"}], PlotStyle -> {Thick, Green}, Frame -> True, PerformanceGoal -> "Quality", ImageSize -> 280 ], Plot[cd[0.8, c0, \[Phi]2, x2], {x2, -200, 200}, PlotRange -> {0, All}, FrameLabel -> {Row[{Style["\[Phi]", Italic], "[mV]"}], Row[{Style["Capacitance", Italic], "(\!$$\*FractionBox[\(\[Micro]F$$, SuperscriptBox[$$cm$$, \ $$2$$]]\))"}]}, PlotLabel -> Row[{"Stern model"}], PlotStyle -> {Thick, Red}, Frame -> True, PerformanceGoal -> "Quality", ImageSize -> 280 ] }} ], {{c0, 0.15, "Initial concentration (M)"}, 0, 1, Appearance -> "Labeled"}, {{x2, 0, "x2 (nm)"}, 0, 2, Appearance -> "Labeled"}, {{\[Phi]2, 200, "\[Phi]2 (mV)"}, 0, 250, Appearance -> "Labeled"}, Initialization :> ( z = 1; T = 300; \[Epsilon]0 = 8.854*10^-12; \[Epsilon] = 80; R = 8.314; F = 96485.33; xmax = 20; \[Kappa][ c0_] := (((2*(c0*1000)*F^2)/(\[Epsilon]*\[Epsilon]0*R*T))^( 1/2)*10^-9); \[Phi][x_, c0_, \[Phi]2_, x2_] := \[Phi]2* Exp[-\[Kappa][c0]*(x - x2)]; cf[x_, c0_, \[Phi]2_, x2_] := c0*Exp[-z*F*\[Phi][x, c0, \[Phi]2, x2]/(1000*R*T)]; cd[x_, c0_ , \[Phi]2_, x2_] := ((x2*10^-11)/(\[Epsilon]*\[Epsilon]0) + ( 1*10^-11)/(\[Epsilon]*\[Epsilon]0*\[Kappa][c0]* Cosh[(z*F*\[Phi][x, c0, \[Phi]2, x2])/(2*1000*R*T)]))^-1; ) ] The $\kappa$ in the definition of cd had no argument and the third plot did not vary or give a value for x - the first input to the function cd.Cheers,Marco
Answer
Posted 1 month ago
 Thank you Marco!!! I just corrected the kappa issue. However, for the third plot, I want to plot [Phi] (not x) in the x-axis and Cd in the y-axis. However both values are functions that depend on x, c0, [Phi]2, x2 and Mathematica for some reason doesn't let me plot the dependence between each other.I tried to use something like this: ParametricPlotPlot[{cd[x, c0, [Phi]2, x2], [Phi][x, c0, [Phi]2, x2]}, {[Phi], -200, 200}, PlotRange -> All, But still doesn't work.Any thoughts?-Vanessa
Answer
Posted 1 month ago
 Vanessa,For ParametricPlot to work $\phi$ cannot simultaneously be a dependent and independent variable. If you let $x$ be the independent variable, you can obtain a ParametricPlot. Manipulate[ Grid[ {{ Plot[\[Phi][x, c0, \[Phi]2, x2], {x, 0, 10}, PlotRange -> {0, 0.3}, FrameLabel -> {Row[{Style["x", Italic], "[nm]"}], Row[{Style["Potential", Italic], "(mV)"}]}, PlotLabel -> Row[{"Potential profile of a monovalent salt"}], PlotStyle -> {Thick, Blue}, Frame -> True, PerformanceGoal -> "Quality", ImageSize -> 280 ], Plot[cf[x, c0, \[Phi]2, x2], {x, 0, 0.5}, PlotRange -> All, FrameLabel -> {Row[{Style["x", Italic], "[nm]"}], Row[{Style["Concentration", Italic], "(M)"}]}, PlotLabel -> Row[{"Concentration profile of a monovalent salt"}], PlotStyle -> {Thick, Green}, Frame -> True, PerformanceGoal -> "Quality", ImageSize -> 280 ], ParametricPlot[{\[Phi][x, c0, \[Phi]2, x2], cd[x, c0, \[Phi]2, x2]}, {x, 0, 10}, FrameLabel -> {Row[{Style["\[Phi]", Italic], "[mV]"}], Row[{Style["Capacitance", Italic], "(\!$$\*FractionBox[\(\[Micro]F$$, SuperscriptBox[$$cm$$, \ $$2$$]]\))"}]}, PlotLabel -> Row[{"Stern model"}], PlotStyle -> {Thick, Red}, Frame -> True, PerformanceGoal -> "Quality", ImageSize -> 280 ] }} ], {{c0, 0.15, "Initial concentration (M)"}, 0, 1, Appearance -> "Labeled"}, {{x2, 0, "x2 (nm)"}, 0, 2, Appearance -> "Labeled"}, {{\[Phi]2, 200, "\[Phi]2 (mV)"}, 0, 250, Appearance -> "Labeled"}, Initialization :> ( z = 1; T = 300; \[Epsilon]0 = 8.854*10^-12; \[Epsilon] = 80; R = 8.314; F = 96485.33; xmax = 20; \[Kappa][ c0_] := (((2*(c0*1000)*F^2)/(\[Epsilon]*\[Epsilon]0*R*T))^( 1/2)*10^-9); \[Phi][x_, c0_, \[Phi]2_, x2_] := \[Phi]2* Exp[-\[Kappa][c0]*(x - x2)]; cf[x_, c0_, \[Phi]2_, x2_] := c0*Exp[-z*F*\[Phi][x, c0, \[Phi]2, x2]/(1000*R*T)]; cd[x_, c0_, \[Phi]2_, x2_] := ((x2*10^-11)/(\[Epsilon]*\[Epsilon]0) + ( 1*10^-11)/(\[Epsilon]*\[Epsilon]0*\[Kappa][c0]* Cosh[(z*F*\[Phi][x, c0, \[Phi]2, x2])/(2*1000*R*T)]))^-1; ) ] `
Answer
Posted 1 month ago
 You are totally right! Thank you all for your help!
Answer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments