Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mr8Manhattan/52ffb72122241b556909a83d5085f2c3 to your computer and use it in GitHub Desktop.
Save Mr8Manhattan/52ffb72122241b556909a83d5085f2c3 to your computer and use it in GitHub Desktop.
Railgun Force Computation With Simple Magnetic Field
Analytic Force Computation Comparison Code
Define Constants
In[15]:= ClearAll[F, Lp, Ic, I0, I1, I2, I3, \[Omega], \[Tau], t, t1, t2, t3, m, V0, \
V2, imp, d, w, x]
\[Mu]0 = 4*\[Pi] *10^(-7);
r = 0.005;
wR = r * 2;
d = sep + r;
w = d + r;
(* Case 1 ICL Force *)
m = 0.00556; (* kg *)
V0 = 0; (* m/s *)
I0 = 20000; (* A *)
t1 = 0.5*^-3; t2 = 0.5*^-3; t3 = 2.5*^-3;
sep = 0.012;
L = 0.2;
wR = 0.01;
Lp = 4.8973*^-7;(*0.9*^-6;*)
\[Tau] = 0.0007;
f = 1/(4*t1);
\[Omega] = 2*\[Pi]*f;
[S1] Simple Force and Velocity Computation - Constant Current
In[32]:= SimpleInt = Integrate[I0^2, {tt, 0, t3}];
Fsimple = Lp/2*
I0^2; \
FsimpleDisp = HoldForm[Lp/2*I0^2];
ImpSimpleInt =
Integrate[Fsimple, {tt, 0, t3}]; ImpsimpleIntDisp1 =
HoldForm[ Integrate[Fsimple, {t, 0, t3}]];
ImpsimpleIntDisp2 = HoldForm[ Integrate[Lp/2*I0^2, {t, 0, t3}] ];
ImpSimple =
Fsimple*t3; \
ImpsimpleDisp = HoldForm[Lp/2*I0^2*t3];
V2simple =
ImpSimple /
m; \
V2simpleDisp = HoldForm[Lp*I0^2*t3/(2*m)];
Results
In[38]:= Print[" ::::::::::::::::: [S1] Simple Results - Constant Current \
::::::::::::::::: "];
Print["The charge used was \!\(\*SuperscriptBox[\(I\), \(2\)]\)t \
= ", I0^2*t3, "[C]"]
Print[" Simple Force \!\(\*SubscriptBox[\(F\), \(S\)]\) = \
", FsimpleDisp, " = ", Fsimple];
Print[" Simple Integrated Impulse \!\(\*SubscriptBox[\(Imp\), \(S\\\ \
Int\)]\) = ", ImpsimpleIntDisp1, " = ", ImpsimpleIntDisp2, " = ", ImpSimple];
Print[" Simple Impulse \!\(\*SubscriptBox[\(Imp\), \(S\)]\) = \
", ImpsimpleDisp, " = ", ImpSimple];
Print[" Simple Velcotiy \!\(\*SubscriptBox[\(V2\), \(S\)]\) = \
", V2simpleDisp, " = ", V2simple];
During evaluation of In[38]:= ::::::::::::::::: [S1] Simple Results - Constant Current :::::::::::::::::
During evaluation of In[38]:= The charge used was I^2t = 1.*10^6[C]
During evaluation of In[38]:= Simple Force Subscript[F, S] = (Lp I0^2)/2 = 97.946
During evaluation of In[38]:= Simple Integrated Impulse Subscript[Imp, S Int] = \!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(t3\)]\(Fsimple \[DifferentialD]t\)\) = \!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(t3\)]\(\*FractionBox[\(Lp\
\*SuperscriptBox[\(I0\), \(2\)]\), \(2\)] \[DifferentialD]t\)\) = 0.244865
During evaluation of In[38]:= Simple Impulse Subscript[Imp, S] = 1/2 Lp I0^2 t3 = 0.244865
During evaluation of In[38]:= Simple Velcotiy Subscript[V2, S] = (Lp I0^2 t3)/(2 m) = 44.0405
[S3] Simple Force and Velocity Computation with Circular Wire Assumption - Constant Current
In[54]:= Bc[x_] := \[Mu]0 * I0 / (2*\[Pi]*x);
FsimpleCDisp =
HoldForm[ Integrate[I0*\[Mu]0 * I0 / (2*\[Pi]*x) , {x, r, (w - r)}] ];
FsimpleC = Integrate[I0*Bc[x], {x, r, (w - r)}] // N;
ImpSimpleCInt = Integrate[FilrA, {tt, 0, t3}]; ImpSimpleCIntDisp = HoldForm[ Integrate[Integrate[I0 * B, {x, r, w - r}], {t, 0, t3}] ];
ImpSimpleC = FsimpleC*t3; ImpSimpleCdisp = HoldForm[Lp/2*I0^2*t3];
V2SimpleC = ImpSimpleC / m; V2SimpleCDisp = HoldForm[FsimpleC*t3/m];
tRail = L / (V2SimpleC / 2); (* Time the armature spends in the barrel *)
Iused = I0^2 * tRail; (* Current used in the shot *)
Results
In[62]:= Print[" ::::::::::::::::: [ILR2] ILR Equivalent Analytical Model Results - \
Constant Current ::::::::::::::::: "];
Print["The charge used was \!\(\*SuperscriptBox[\(I\), \(2\)]\
\)t = ", Iused, "[C]"]
Print["Simple Circular Force \!\(\*SubscriptBox[\(F\), \
\(SC\)]\) = ", FsimpleCDisp, " = ", FsimpleC];
Print["Simple Circular Impulse \!\(\*SubscriptBox[\(Imp\), \
\(SC\)]\) = ", ImpSimpleCIntDisp, " = ", ImpSimpleCInt];
Print["Simple Circular Impulse \!\(\*SubscriptBox[\(Imp\), \
\(SC\)]\) = ", ImpSimpleCdisp, " = ", ImpSimpleC];
Print["Simple Circular Velcotiy \!\(\*SubscriptBox[\(V\), \(2\\\ SC\
\)]\) = ", V2SimpleCDisp, " = ", V2SimpleC];
During evaluation of In[62]:= ::::::::::::::::: [ILR2] ILR Equivalent Analytical Model Results - Constant Current :::::::::::::::::
During evaluation of In[62]:= The charge used was I^2t = 3.63465*10^6[C]
During evaluation of In[62]:= Simple Circular Force Subscript[F, SC] = \!\(
\*SubsuperscriptBox[\(\[Integral]\), \(r\), \(w - r\)]\(
\*FractionBox[\(I0\ \[Mu]0\ I0\), \(2\ \[Pi]\ x\)] \[DifferentialD]x\)\) = 97.902
During evaluation of In[62]:= Simple Circular Impulse Subscript[Imp, SC] = \!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(t3\)]\(\((
\*SubsuperscriptBox[\(\[Integral]\), \(r\), \(w - r\)]\(I0\ B\) \[DifferentialD]x)\) \[DifferentialD]t\)\) = 0.0025 FilrA
During evaluation of In[62]:= Simple Circular Impulse Subscript[Imp, SC] = 1/2 Lp I0^2 t3 = 0.244755
During evaluation of In[62]:= Simple Circular Velcotiy Subscript[V, 2 SC] = (FsimpleC t3)/m = 44.0207
[ILR1] Analytically Compute Force and Velocity from ILR Model (1D Biot-Savart) - Constant Current
In[68]:= B[x_] := \[Mu]0 * I0 / (4*\[Pi]*x) * (L / Sqrt[L^2 + x^2]);
FilrADisp =
HoldForm[ Integrate[
2*I0*\[Mu]0 * I0 / (4*\[Pi]*x) * (L / Sqrt[L^2 + x^2]), {x, r, (w - r)}] ];
FilrA = Integrate[I0*2*B[x], {x, r, (w - r)}] // N;
ImpILRaInt = Integrate[FilrA, {tt, 0, t3}]; ImpILRaIntDisp =
HoldForm[ Integrate[Integrate[I0 * B, {x, r, w - r}], {t, 0, t3}] ];
ImpILRa = Filr*
t3; \
ImpILRadisp = HoldForm[Lp/2*I0^2*t3];
V2ilrA = ImpILRa /
m; V2ilrADisp =
HoldForm[FilrA*t3/m];
tRail = L / (V2ilr /
2); (* Time the armature spends in the barrel *)
Iused = I0^2 *
tRail; (* Current used in the shot *)
Results
In[115]:= Print[" ::::::::::::::::: [ILR1] ILR Analytical Model Results - Constant \
Current ::::::::::::::::: "];
Print["The charge used was \!\(\*SuperscriptBox[\(I\), \(2\)]\)t \
= ", Iused, "[C]"]
Print[" ILR Analytic Force 2*\!\(\*SubscriptBox[\(F\), \(ILR\\\ \
A\)]\) = ", FilrADisp, " = ", FilrA];
Print[" ILR Integrated Impulse \!\(\*SubscriptBox[\(Imp\), \(ILR\\\ A\\\ \
Int\)]\) = ", ImpILRaIntDisp, " = ", ImpILRaInt];
Print[" ILR Analytic Impulse \!\(\*SubscriptBox[\(Imp\), \(ILR\\\ \
A\)]\) = ", ImpILRadisp, " = ", ImpILRa];
Print[" ILR Analytic Velcotiy \!\(\*SubscriptBox[\(V\), \(2\\\ ILR\\\ A\
\)]\) = ", V2ilrADisp, " = ", V2ilrA];
Plot[B[x], {x, r, sep},
AxesLabel -> {"Distance [m]", "Magnetic Field Strength [T]"},
PlotLabel -> "Magnetic Field Strength"]
During evaluation of In[115]:= ::::::::::::::::: [ILR1] ILR Analytical Model Results - Constant Current :::::::::::::::::
During evaluation of In[115]:= The charge used was I^2t = 1.6*10^8/V2ilr[C]
During evaluation of In[115]:= ILR Analytic Force 2*Subscript[F, ILR A] = \!\(
\*SubsuperscriptBox[\(\[Integral]\), \(r\), \(w - r\)]\(
\*FractionBox[\(2\ I0\ \[Mu]0\ I0\ L\), \(\((4\ \[Pi]\ x)\)\
\*SqrtBox[\(
\*SuperscriptBox[\(L\), \(2\)] +
\*SuperscriptBox[\(x\), \(2\)]\)]\)] \[DifferentialD]x\)\) = 97.7704
During evaluation of In[115]:= ILR Integrated Impulse Subscript[Imp, ILR A Int] = \!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(t3\)]\(\((
\*SubsuperscriptBox[\(\[Integral]\), \(r\), \(w - r\)]\(I0\ B\) \[DifferentialD]x)\) \[DifferentialD]t\)\) = 0.244426
During evaluation of In[115]:= ILR Analytic Impulse Subscript[Imp, ILR A] = 1/2 Lp I0^2 t3 = 0.0025 Filr
During evaluation of In[115]:= ILR Analytic Velcotiy Subscript[V, 2 ILR A] = (FilrA t3)/m = 0.44964 Filr
Out[121]= \!\(\*
GraphicsBox[{{{}, {},
{RGBColor[0.368417, 0.506779, 0.709798], AbsoluteThickness[1.6], Opacity[1.],
LineBox[CompressedData["
1:eJwVxX041AcAB3BOVnnrmi0VJrm0J5WS6prTtynZKvKS0+s13UnkLZ2XO2/nnPNzyduEXlSeC0OpmDK2Vep3zhHukLvHpk55yyQPteGhbX98no/1qXDvAIqO
jo77f/6/F0leWj4XYoIvvFigwWcFNtetE7j4VPw9/bc8DTa9a3rrn8RF/12XjLEcDUTXqKL+FC7COf3GnhkabJwufvA6g4uVB+0iLZI1EFQ/Mx+8zsW9GFmO
KlgD2hqDwbeNXHzgquTVOzUINbjEnzKIguUIw4k+rIZGscrYtiwKnDU64jBHNXzLZtRz9GgYN/jVx1zqQYdz6u7ppmi4cr87wtTtAU2RambKjsGqhjmr0jMv
kB7ZReucjEF97LzUUtsNOfXy1f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/BREqwaDt1PRMDE5Kucnw+ToESEGfunEzgX0RDicYiE3ct7QqmEwDC10W6rD4lDHpN/D1wgEG91eaGFN4nS9bH9wZkEqhSlX749SKL9ar3f
nSwCnAtdbkoPEv8YzLWOZxM4S3mSX+dOwpoPF4dcAiueBVJuHiCxbyT5IfdHAtKAZ5K0/ST+BYFbVMM=
"]]}}, {}},
AspectRatio->0.6180339887498948,
Axes->{True, True},
AxesLabel->{FormBox["\"Distance [m]\"", TraditionalForm],
FormBox["\"Magnetic Field Strength [T]\"", TraditionalForm]},
AxesOrigin->{0.005, 0.17},DisplayFunction->Identity,
Frame->{{False, False}, {False, False}},FrameLabel->{{None, None}, {None, None}},
FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}},
GridLines->{None, None},GridLinesStyle->Directive[GrayLevel[0.5, 0.4]],ImagePadding->All,ImageSize->{850., Automatic},
Method->{"DefaultBoundaryStyle" -> Automatic,
"DefaultMeshStyle" -> AbsolutePointSize[6], "ScalingFunctions" -> None},
PlotLabel->FormBox["\"Magnetic Field Strength\"", TraditionalForm],
PlotRange->{{0.005, 0.012}, {0.1663674762319661, 0.39987504713111155`}},
PlotRangeClipping->True,
PlotRangePadding->{{Scaled[0.02], Scaled[0.02]}, {Scaled[0.05], Scaled[0.05]}},Ticks->{Automatic, Automatic}]\)
[ILR2] Use Analytic Equivalent to Compute Force and Velocity from ILR Model (1D Biot-Savart) - Constant Current
In[84]:= F1 = Log[(L + Sqrt[L^2 + d^2])/d];
F2 = Log[(L + Sqrt[L^2 + r^2])/r];
F3 = Log[(L + Sqrt[L^2 + (w - r)^2])/(w - r)];
F4 = Log[(L + Sqrt[L^2 + (w - d)^2])/(w - d)];
FilrE = \[Mu]0 * I0^2/ (4*\[Pi]) * ( -F1 + F2 - F3 + F4) // N;
FilrEDisp =
HoldForm[ \[Mu]0 * I0^2/ (4*\[Pi]) * ( -Log[(L + Sqrt[L^2 + d^2])/d]
+ Log[(L + Sqrt[L^2 + r^2])/r]
- Log[(L + Sqrt[L^2 + (w - r)^2])/(w - r)]
+ Log[(L + Sqrt[L^2 + (w - d)^2])/(w - d)])];
ImpILReInt = Integrate[FilrE, {tt, 0, t3}]; ImpILReIntDisp =
HoldForm[ Integrate[Integrate[I0 * B, {x, r, w - r}], {t, 0, t3}] ];
ImpILRe = Filr*
t3; \
ImpILRedisp = HoldForm[Lp/2*I0^2*t3];
V2ilrE = ImpILR /
m; V2ilrEDisp =
HoldForm[Filr*t3/m];
tRail = L / (V2ilrE /
2); (* Time the armature spends in the barrel *)
Iused = I0^2 * tRail; (* Current used in the shot *)
Results
In[95]:= Print[" ::::::::::::::::: [ILR2] ILR Equivalent Analytical Model Results - \
Constant Current ::::::::::::::::: "];
Print["The charge used was \!\(\*SuperscriptBox[\(I\), \(2\)]\
\)t = ", Iused, "[C]"]
Print[" ILR Equivalent Force \!\(\*SubscriptBox[\(F\), \(ILR\\\ E\
\)]\) = ", FilrEDisp, " = ", FilrE];
Print[" ILR Integrated Impulse \!\(\*SubscriptBox[\(Imp\), \(ILR\\\ E\\\
\ Int\)]\) = ", ImpILReIntDisp, " = ", ImpILReInt];
Print[" ILR Equivalent Impulse \!\(\*SubscriptBox[\(Imp\), \(ILR\\\ \
E\)]\) = ", ImpILRedisp, " = ", ImpILRe];
Print[" ILR Equivalent Velcotiy \!\(\*SubscriptBox[\(V\), \(2\\\ ILR\
\\\ E\)]\) = ", V2ilrEDisp, " = ", V2ilrE];
During evaluation of In[95]:= ::::::::::::::::: [ILR2] ILR Equivalent Analytical Model Results - Constant Current :::::::::::::::::
During evaluation of In[95]:= The charge used was I^2t = 889600./ImpILR[C]
During evaluation of In[95]:= ILR Equivalent Force Subscript[F, ILR E] = (\[Mu]0 I0^2 (-Log[(L+Sqrt[L^2+d^2])/d]+Log[(L+Sqrt[L^2+r^2])/r]-Log[(L+Sqrt[L^2+(w-r)^2])/(w-r)]+Log[(L+Sqrt[L^2+(w-d)^2])/(w-d)]))/(4 \[Pi]) = 97.7704
During evaluation of In[95]:= ILR Integrated Impulse Subscript[Imp, ILR E Int] = \!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(t3\)]\(\((
\*SubsuperscriptBox[\(\[Integral]\), \(r\), \(w - r\)]\(I0\ B\) \[DifferentialD]x)\) \[DifferentialD]t\)\) = 0.244426
During evaluation of In[95]:= ILR Equivalent Impulse Subscript[Imp, ILR E] = 1/2 Lp I0^2 t3 = 0.0025 Filr
During evaluation of In[95]:= ILR Equivalent Velcotiy Subscript[V, 2 ILR E] = (Filr t3)/m = 179.856 ImpILR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment