Computer Program to calculate the pressure distribution on a conducting gas inside a solenoid carrying current (Visual Basic)

 

Private Sub cmdCalculate_Click()

 

Rem to calculate magnetic flux of solenoid

pi = 3.1415926

rt = txtDiameter.Text / 2: delta_psi_deg = 10

A = pi * 0.0000004: i = Val(txtCurrent.Text): Rem 1000A/M

total_force = 0: length = Val(txtLength.Text): Rem metres

delta_d = length / 50: Rem  metres

delta_l = (delta_psi_deg * pi / 180) * rt: total_flux = 0

filenum = FreeFile(0)

FileName = txtFileName.Text

Open FileName For Output As filenum

Print #filenum, "Coil diameter "; txtDiameter.Text; "meter length "; txtLength.Text; "meter current "; txtCurrent.Text; "Amp"

Print #filenum, "No loss in induced current in surface layer of plasma"

Print #filenum, " "

Print #filenum, Tab(10); "Mag Flux (Wb/M^2)"; Tab(30); "pressure Pa";

Print #filenum, Tab(50); "Dist from Centre (meter)"

Print #filenum, " "

dr0_l = 1

x = 0: y = 0

For testpoint = 0 To length / 2 Step length / 20

        Print #filenum, "test point = "; testpoint; " meter"

For r0_l = 0 To 9 Step dr0_l

        r0 = r0_l * rt * 0.1

        Rem startpoint = -length / 2: finsishpoint = length / 2

       

        startpoint = length - testpoint: finishpoint = length + testpoint

        For d = startpoint To finishpoint Step delta_d

        For psi_deg = -180 To 170 Step delta_psi_deg

            psi = psi_deg * pi / 180

                        GoSub find

                        GoSub force

                        total_force = total_force + f

                        ra = r0: rb = r0 + rt * 0.1 * dr0_l

                        total_flux = total_flux + f * pi * (ra + rb) * (rb - ra)

        Next

       

        Next

       

        Rem If (Int(r0_l / 10)) * 10 = r0_l Then

        Print #filenum, Tab(13); " ";

        Print #filenum, total_flux;

        Print #filenum, Tab(29); " ";

        Print #filenum, total_force * i;

        Print #filenum, Tab(59); " ";

        Print #filenum, r0

        Rem End If

       

        Next

       

       

 

       Print #filenum, " "

       Print #filenum, "Total Flux="; total_flux

      

        Next

      

        Close #filenum

GoTo Fin

force:

        f = A * i * delta_d * delta_l * sin_chi * cos_sigma / sep_sq

Return

find:

Rem find sin_chi

cos_chi_sq = (rt * rt * Cos(psi) * Sin(psi) + rt * Sin(psi) * (rt * Cos(psi) - r0)) ^ 2

div = rt ^ 2 * ((rt * Sin(psi)) ^ 2 + (rt * Cos(psi) - r0) ^ 2 + d ^ 2)

If div = 0 Then

cos_chi_sq = 1

Else

cos_chi_sq = cos_chi_sq / div

End If

If cos_chi_sq > 1 Then cos_chi_sq = 1

sin_chi = Sqr(1 - cos_chi_sq)

Rem find cos_sigma

cos_sigma = rt * Cos(psi) * (rt * Cos(psi) - r0) - (rt * Sin(psi)) ^ 2

div = Sqr((d * rt) ^ 2 + (rt * Cos(psi) * (rt * Cos(psi) - r0) - (rt * Sin(psi)) ^ 2) ^ 2)

If div = 0 Then

cos_sigma = 1

Else

cos_sigma = Abs(cos_sigma / div)

End If

Rem find sep_sq

sep_sq = (rt * Sin(psi)) ^ 2 + (rt * Cos(psi) - r0) ^ 2 + d ^ 2

Rem end of find

Return

Rem End of text

Fin:

ret = MsgBox("Finished")

End Sub

 

 

 

 

 

 

 

Private Sub cmdEndProgram_Click()

End

End Sub

 

OutPut

 

Coil diameter .5meter length .5meter current 300Amp

No loss in induced current in surface layer of plasma

 

         Mag Flux (Wb/M^2)   pressure Pa         Dist from Centre (meter)

 

test point =  0  meter

              1.06471432234873E-08

                              1.62676368262196E-03          0

              4.24450800246661E-08

                              3.24621933329691E-03          0.025

              9.47290539136782E-08

                              4.84389991522379E-03          0.05

              1.67319068163014E-07

                              6.42831954273924E-03          0.075

              2.60128054940901E-07

                              8.00389386391442E-03          0.1

              3.71994671032517E-07

                              9.55770842871294E-03          0.125

              5.01913128861287E-07

                              1.10846375449005E-02          0.15

              6.50480545208382E-07

                              1.25979328471325E-02          0.175

              8.163357962566E-07

                              1.40885690914064E-02          0.2

              1.00162236316425E-06

                              1.55785534374231E-02          0.225

 

Total Flux= 1.00162236316425E-06

test point =  0.025  meter

              1.06577411630985E-06

                              2.53802194809099E-02          0

              1.25736188920667E-06

                              3.51377047969534E-02          0.025

              1.57236671434889E-06

                              4.47635433648355E-02          0.05

              2.00968143634808E-06

                              5.43087960569897E-02          0.075

              2.56874619783144E-06

                              6.37997743840688E-02          0.1

              3.24251805839623E-06

                              7.31583888382645E-02          0.125

              4.02488757090155E-06

                              8.23535625512736E-02          0.15

              4.91941903574186E-06

                              9.14651853870576E-02          0.175

              5.91785854046903E-06

                              0.100438733731502             0.2

              7.03312034089438E-06

                              0.109407126055228             0.225

 

Total Flux= 7.03312034089438E-06

test point =  0.05  meter

              7.15193842857283E-06

                              0.127561192908343             0

              7.50677305377126E-06

                              0.145632772282368             0.025

              8.09011974239271E-06

                              0.163458534320278             0.05

              8.89982705046954E-06

                              0.181131986581261             0.075

              9.9347003552873E-06

                              0.198700541754078             0.1

              1.11814905878245E-05

                              0.216018316173734             0.125

              1.2628660163673E-05

                              0.233026872143017             0.15

              1.42826604813181E-05

                              0.249874381321848             0.175

              1.6127965216212E-05

                              0.266459193091017             0.2

              1.81884921010594E-05

                              0.283028946928052             0.225

 

Total Flux= 1.81884921010594E-05

test point =  0.075  meter

              1.83565995076345E-05

                              0.308713867103911             0

              1.8858583990984E-05

                              0.334279727341777             0.025

              1.96836114349503E-05

                              0.359490709383423             0.05

              2.0828276792749E-05

                              0.384475278935975             0.075

              2.2290330763675E-05

                              0.409295878456971             0.1

              2.40503086345533E-05

                              0.433741770761913             0.125

              2.60911045498577E-05

                              0.45772720559044              0.15

              2.84212905187496E-05

                              0.481462285372759             0.175

              3.101805684355E-05

                              0.504800913346209             0.2

              3.39151583957236E-05

                              0.528097993288925             0.225

 

Total Flux= 3.39151583957236E-05

test point =  0.1  meter

              3.41441200971506E-05

                              0.563080764984061             0

              3.48277724792556E-05

                              0.597898895487938             0.025

              3.59511287036231E-05

                              0.632226133698033             0.05

              3.75091682093219E-05

                              0.666233405893827             0.075

              3.94982144961486E-05

                              0.700000504985782             0.1

              4.18909431391521E-05

                              0.733235233495534             0.125

              4.46631601322545E-05

                              0.765817046071667             0.15

              4.78259470956531E-05

                              0.798032930088186             0.175

              5.13472442152465E-05

                              0.829680846449887             0.2

              5.52730716683609E-05

                              0.861250439151223             0.225

 

Total Flux= 5.52730716683609E-05

test point =  0.125  meter

              5.55672158067292E-05

                              0.90619235377655              0

              5.64454188277702E-05

                              0.950918867127309             0.025

              5.78880634546309E-05

                              0.995002840389352             0.05

              5.98880958254868E-05

                              1.03865747493958              0.075

              6.24398075769928E-05

                              1.08197667979563              0.1

              6.55067639508612E-05

                              1.12457635474616              0.125

              6.90563993545352E-05

                              1.16629515083026              0.15

              7.31019770988191E-05

                              1.20750306805579              0.175

              7.76006265374068E-05

                              1.24793501013214              0.2

              8.26115949451676E-05

                              1.28823077798275              0.225

 

Total Flux= 8.26115949451676E-05

test point =  0.15  meter

              8.29765829062874E-05

                              1.34399683158797              0

              8.40661918162289E-05

                              1.3994901586319               0.025

              8.58555651110189E-05

                              1.45416937970589              0.05

              8.83350950041901E-05

                              1.50828998941204              0.075

              9.14962635317874E-05

                              1.56195565401959              0.1

              9.52918697711381E-05

                              1.61467619266638              0.125

              9.96792464042278E-05

                              1.66624094517887              0.15

              1.04673385996655E-04

                              1.71711083421467              0.175

              1.10218443731551E-04

                              1.76694744767121              0.2

              1.16388221694073E-04

                              1.81656179768038              0.225

 

Total Flux= 1.16388221694073E-04

test point =  0.175  meter

              1.16831219320014E-04

                              1.88424685030367              0

              1.18153576774957E-04

                              1.95159396360883              0.025

              1.20324460814079E-04

                              2.01793129447589              0.05

              1.23331104546257E-04

                              2.08355719896803              0.075

              1.27161231328156E-04

                              2.14857945181136              0.1

              1.31754756131542E-04

                              2.21238298849309              0.125

              1.37056638837881E-04

                              2.27469591315536              0.15

              1.43082986083323E-04

                              2.33607978318808              0.175

              1.49762023105148E-04

                              2.3961081187316               0.2

              1.57183898319142E-04

                              2.45579122512999              0.225

 

Total Flux= 1.57183898319142E-04

test point =  0.2  meter

              1.57713780830813E-04

                              2.53675131066188              0

              1.59295336460383E-04

                              2.6172992788265               0.025

              1.61890906626282E-04

                              2.69661406201205              0.05

              1.65483921078236E-04

                              2.77503865909325              0.075

              1.70057250418344E-04

                              2.85267791064328              0.1

              1.75535288550612E-04

                              2.92876723678742              0.125

              1.81847688377663E-04

                              3.00295674957894              0.15

              1.89010833259458E-04

                              3.07591994544888              0.175

              1.96932977603145E-04

                              3.1471207993045               0.2

              2.05723001399772E-04

                              3.21780589038623              0.225

 

Total Flux= 2.05723001399772E-04

test point =  0.225  meter

              2.06350584960778E-04

                              3.31369359692163              0

              2.08223601292331E-04

                              3.40908553699954              0.025

              2.11296651458014E-04

                              3.50299103445508              0.05

              2.15548773236638E-04

                              3.59580194342524              0.075

              2.20956822347001E-04

                              3.6876118381538               0.1

              2.27426477164404E-04

                              3.77747460718817              0.125

              2.34868335714486E-04

                              3.86493862645514              0.15

              2.43297905308263E-04

                              3.95080151873493              0.175

              2.52597884032172E-04

                              4.03438576022997              0.2

              2.62899024777097E-04

                              4.11722251797346              0.225

 

Total Flux= 2.62899024777097E-04

test point =  0.25  meter

              2.63637308750477E-04

                              4.23002400191582              0

              2.65840609844166E-04

                              4.34223720708769              0.025

              2.69454899280657E-04

                              4.45268175865147              0.05

              2.74454468351624E-04

                              4.56180717276078              0.075

              2.80809100597099E-04

                              4.66968676216351              0.1

              2.88402026584313E-04

                              4.7751516398953               0.125

              2.97120059295537E-04

                              4.87761450933751              0.15

              3.06976215774798E-04

                              4.97800849655798              0.175

              3.17819768393364E-04

                              5.07546572174543              0.2

              3.29807419192529E-04

                              5.17186457210123              0.225

 

Total Flux= 3.29807419192529E-04


 

  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

Pressure distribution at end of solenoid (point 0)


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

These graphs show that the pressure is highest near the wire and near the midpoint of the solenoid and diminishes towards the axis and towards the ends.

 

This would indicate that hydrogen plasma would be forced to the axis but more so near the mid point. There was no indication of any longitudinal force in my calculations but I did not resolve along the axis.

Graph showing outward force inside solenoid along axis as a function of distance from midpoint of solenoid.

 

This shows that ionized gas carrying a current will be ejected from the ends of the solenoid but close to the midpoint no force would be felt.

 

This indicates that a solenoid is less suitable than a Toroid for containment.

 

This graph was calculated by a small visual basic program which I include below.

Manual adjustment was needed.

 

 

 

 

 

 

Private Sub cmdCalculate_Click()

length = Val(txtLength.Text): r = Val(txtDiameter.Text) / 2

i = Val(txtCurrent.Text)

filenum = FreeFile(0)

FileName = txtFileName.Text

Open FileName For Output As filenum

For b =  - length / 2 To length / 2 Step length / 10

For d = -length / 2 To length / 2 Step length / 10

f0 = 4 * 0.00000031415926 * 2 * 3.1415926 * r * i * i * (d - b) / Sqr(r * r + (d - b) ^ 2) * (length / 10) ^ 2

F = F + f0

Next

Print #filenum, F; " "; b

F = 0

Next

Close #filenum

MsgBox ("Finished")

End Sub

 

Private Sub cmdEnd_Click()

End

End Sub