mirror of
https://gitlab.com/Anson-Projects/projects.git
synced 2025-06-16 06:56:46 +00:00
69 lines
17 KiB
JSON
69 lines
17 KiB
JSON
[
|
||
{
|
||
"path": "posts/2021-08-24-julia-for-matlabbers/",
|
||
"title": "Julia for Matlabbers",
|
||
"description": "Everything a Matlab programmer needs to know about Julia.",
|
||
"author": [
|
||
{
|
||
"name": "Anson Biggs",
|
||
"url": "https://ansonbiggs.com"
|
||
}
|
||
],
|
||
"date": "2021-08-24",
|
||
"categories": [
|
||
"Julia",
|
||
"Matlab"
|
||
],
|
||
"contents": "\r\nPluto is a harder format to work this than I initially thought so if the notebook does not show up below you can find it at https://julia.ansonbiggs.com/ or the repository https://gitlab.com/MisterBiggs/julia-for-matlabbers\r\n\r\n\r\n\r\n\r\n\r\n",
|
||
"preview": "posts/2021-08-24-julia-for-matlabbers/preview.png",
|
||
"last_modified": "2021-08-24T15:35:37-07:00",
|
||
"input_file": "julia-for-matlabbers.knit.md",
|
||
"preview_width": 500,
|
||
"preview_height": 300
|
||
},
|
||
{
|
||
"path": "posts/2021-04-14-iss-eclipse-determination/",
|
||
"title": "ISS Eclipse Determination",
|
||
"description": "Determining how much sunlight a body orbiting a planet is receiving.",
|
||
"author": [
|
||
{
|
||
"name": "Anson Biggs",
|
||
"url": "https://ansonbiggs.com"
|
||
}
|
||
],
|
||
"date": "2021-05-01",
|
||
"categories": [
|
||
"Julia",
|
||
"Astrodynamics"
|
||
],
|
||
"contents": "\r\nDetermining the eclipses a satellite will encounter is a major driving factor when designing a mission in space. Thermal and power budgets have to be made with the fact that a satellite will periodically be in the complete darkness of space where it will receive no solar radiation to power the solar panels and keep the spacecraft from freezing.\r\nWhat is an Eclipse\r\nGeometry of an EclipseThe above image is a simple representation of what an eclipse is. First, you’ll notice the Umbra is complete darkness, then the Penumbra, which is a shadow of varying darkness, and then the rest of the orbit is in full sunlight. For this example, I will be using the ISS, which has a very low orbit, so the Penumbra isn’t much of a problem. However, you can tell by looking at the diagram that higher altitude orbits would spend more time in the Penumbra.\r\nBody Radius’s and Position VectorsHere is a more detailed view of the eclipse that will make it easier to explain what is going on. There are 2 Position vectors, and 2 radius that need to be known for simple eclipse determination. More advanced cases where the atmosphere of the body your orbiting can significantly affect the Umbra and Penumbra, and other bodies could also potentially block the Sun. However, we will keep it simple for this example since they have minimal effect on the ISS’s orbit. Rsun and Rbody are the radius of the Sun and Body (In this case Earth), respectively. r_sun_body is a vector from the center of the Sun to the center of the target body. For this example I will only be using one vector, but for more rigorous eclipse determination it is important to calculate the ephemeris at least once a day since it does significantly change over the course of a year. The reason that I am ignoring it at the moment is because there is currently no good way to calculate Ephemerides in Julia but the package is being worked on so I may revisit this and do a more rigorous analysis in the future. r_body_sc is a position vector from the center of the body being orbited, to the center of our spacecraft.\r\nThe Code\r\n\r\n\r\nShow code\r\nusing Unitful\r\nusing LinearAlgebra\r\nusing SatelliteToolbox\r\nusing Plots\r\nusing Colors\r\ntheme(:ggplot2)\r\n\r\nTo get the orbit for the ISS, I used a Two-Line Element which is a data format for explaining orbits. The US Joint Space Operations Center makes these widely available, but https://live.ariss.org/tle/ makes the TLE for the ISS way more accessible (“ARISS TLE,” n.d.). The Julia Package SatelliteToolbox.jl makes it super easy to turn a TLE into an orbit that can be propagated. Simply putting the TLE in a string and using the tle string macro like below, we now have access to the information to start making our ISS orbit.\r\n\r\nISS = tle\"\"\"\r\nISS (ZARYA)\r\n1 25544U 98067A 21103.84943184 .00000176 00000-0 11381-4 0 9990\r\n2 25544 51.6434 300.9481 0002858 223.8443 263.8789 15.48881793278621\r\n\"\"\"\r\n1-element Vector{TLE}:\r\n TLE: ISS (ZARYA) (Epoch = 2021-04-13T20:23:10.911)\r\n\r\nNow that we have the TLE, we can pass that into SatelliteToolbox’s orbit propagator. Before propagating the orbit, we need to have a range of time steps to pass into the propagator. The TLE gives the mean motion, n, which is the revolutions per day, so using that, we can calculate the amount of time required for one orbit, which is all that we’re worried about for this analysis. The propagator returns a tuple containing the Orbital elements, a position vector with units meters, and a velocity vector with units meters per second. For this analysis were only worried about the position vector.\r\n\r\nISS[1].n\r\n\r\n\r\norbit = init_orbit_propagator(Val(:twobody), ISS[1]);\r\ntime = 0:0.1:((24 / ISS[1].n) .* 60 * 60); # ISS[1].n gives the mean motion, or orbits per day.\r\no, r, v = propagate!(orbit, time);\r\n\r\nWe just need to use the radii and vectors discussed earlier to determine if the ISS is in the penumbra or umbra. This is a lot of trigonometry and vector math that I won’t bore anyone with. However, using the diagrams above and following the code in the sunlight function, you should follow what’s happening. For a rigorous discussion, check out (Vallado 1997).\r\n\r\nfunction sunlight(Rbody, r_sun_body, r_body_sc)\r\n Rsun = 695_700u\"km\"\r\n \r\n hu = Rbody * norm(r_sun_body) / (Rsun - Rbody)\r\n \r\n θe = acos((r_sun_body ⋅ r_body_sc) / (norm(r_sun_body) * norm(r_body_sc)))\r\n\r\n θu = atan(Rbody / hu)\r\n du = hu * sin(θu) / sin(θe + θu)\r\n\r\n θp = π - atan(norm(r_sun_body) / (Rsun + Rbody))\r\n dp = Rbody * sin(θp) / cos(θe - θp)\r\n\r\n S = 1\r\n if (θe < π / 2) && (norm(r_body_sc) < du)\r\n S = 0\r\n end\r\n if (θe < π / 2) && ((du < norm(r_body_sc)) && (norm(r_body_sc) < dp))\r\n S = (norm(r_body_sc .|> u\"km\") - du) / (dp - du) |> ustrip\r\n end\r\n\r\n return S\r\nend\r\n\r\nThen we can pass all the values we’ve gathered into the function we just made.\r\n\r\nS = r .|> R -> sunlight(6371u\"km\", [0.5370, 1.2606, 0.5466] .* 1e8u\"km\", R .* u\"m\");\r\n\r\nPlotting the Results\r\nThe sunlight function returns values from 0 to 1, 0 being complete darkness, 1 being complete sunlight, and anything between being the fraction of light being received. Again since the ISS has a very low orbit, the amount of time spent in the penumbra is almost insignificant.\r\n\r\n\r\nShow code\r\n# Get fancy with the line color. \r\nlight_range = range(colorant\"black\", stop = colorant\"orange\", length = 101);\r\nlight_colors = [light_range[unique(round(Int, 1 + s * 100))][1] for s in S];\r\n\r\nplot(\r\n LinRange(0, 24, length(S)),\r\n S .* 100,\r\n linewidth = 5,\r\n legend = false,\r\n color = light_colors,\r\n);\r\n\r\nxlabel!(\"Time (hr)\");\r\nylabel!(\"Sunlight (%)\");\r\ntitle!(\"ISS Sunlight Over a Day\")\r\n\r\n\r\nFigure 1: ISS Sunlight\r\n\r\n\r\n\r\nLooking at the plot, the vertical transition from 0% to 100% makes it pretty clear that the time in the penumbra is limited. Still, almost counterintuitively, it also looks like the ISS gets more sunlight than it does darkness. So, using the raw sunlight data, we can calculate precisely how much time is spent in each region.\r\nTime in Sun:\r\n\r\nsun = length(S[S.==1])/length(S) * 100\r\n62.03323593209401\r\n\r\nTime in Darkness:\r\n\r\numbra = length(S[S.==0])/length(S) * 100\r\n37.64408511553699\r\n\r\nTime in Penumbra:\r\n\r\npenumbra = 100 - umbra - sun\r\n0.322678952369003\r\n\r\nThis means that even with the ISS’s low orbit, it still gets sunlight ~62% of the time and spends almost no time in the penumbra. This would vary a few percent depending on the time of year, but in a circular orbit like the ISS, the amount of sunlight would remain pretty constant. There are other orbits like a polar orbit, lunar orbit, or highly elliptic earth orbits that can have their time in the sunlight vary widely by the time of year.\r\n\r\n\r\n\r\n“ARISS TLE.” n.d. Amateur Radio on the International Space Station. https://live.ariss.org/tle/.\r\n\r\n\r\nVallado, David A. 1997. Fundamentals of Astrodynamics and Applications, 2nd. Ed. Edited by Wiley Larson. Dordrecht: Microcosm, Inc.\r\n\r\n\r\n\r\n\r\n",
|
||
"preview": "posts/2021-04-14-iss-eclipse-determination/preview.png",
|
||
"last_modified": "2021-08-24T06:53:55+00:00",
|
||
"input_file": {},
|
||
"preview_width": 1292,
|
||
"preview_height": 703
|
||
},
|
||
{
|
||
"path": "posts/2021-04-01-air-propulsion-simulation/",
|
||
"title": "Air Propulsion Simulation",
|
||
"description": "Simulating the performance of an air propulsion system as an alternative to solid rocket motors.",
|
||
"author": [
|
||
{
|
||
"name": "Anson Biggs",
|
||
"url": "https://ansonbiggs.com"
|
||
}
|
||
],
|
||
"date": "2021-04-01",
|
||
"categories": [
|
||
"Julia",
|
||
"Capstone"
|
||
],
|
||
"contents": "\r\nFor Capstone my team was tasked with designing a system capable of moving mining equipment and materials around the surface of the Moon using a propulsive landing. The system had to be tested on Earth with something feasible for our team to build in 2 semesters. One of the first considerations my capstone advisor wanted was to test the feasibility of an air propulsion system instead of the obvious solution that of using solid rocket motors. This document is just napkin math to determine if the system is even feasibly and is not meant to be a rigorous study of an air propulsion system that would easily keep a capstone team busy by itself.\r\n\r\n\r\nShow code\r\nusing Plots\r\ntheme(:ggplot2); # In true R spirit\r\n\r\nusing Unitful\r\nusing DataFrames\r\nusing Measurements\r\nusing Measurements: value, uncertainty\r\nusing CSV\r\n\r\nThe Simulation\r\nI chose an off-the-shelf paintball gun tank for the pressure vessel. The primary consideration was the incredible pressure to weight ratio, and the fact that it is designed to be bumped around would be necessary for proving the safety of the system further into the project.\r\n\r\n# Tank https://www.amazon.com/Empire-Paintball-BASICS-Pressure-Compressed/dp/B07B6M48SR/\r\nV = (85 ± 5)u\"inch^3\"\r\nP0 = (4200.0 ± 300)u\"psi\"\r\nWtank = (2.3 ± 0.2)u\"lb\"\r\nPmax = (250 ± 50)u\"psi\" # Max Pressure that can come out the nozzle\r\n\r\nThe nozzle diameter was changed until the air prop system had a burn time similar to a G18ST rocket motor. The propulsion system’s total impulse is not dependant on the nozzle diameter, so this was just done to make it plot nicely with the rest of the rocket motors since, at this time, it is unknown what the optimal thrust profile is.\r\n\r\n# Params\r\nd_nozzle = ((1 // 18) ± 0.001)u\"inch\"\r\na_nozzle = (pi / 4) * d_nozzle^2\r\n\r\nThese are just universal values for what a typical day would look like during the summer in Northern Arizona. (Çengel and Boles 2015)\r\n\r\n# Universal Stuff\r\nP_amb = (1 ± 0.2)u\"atm\"\r\nγ = 1.4 ± 0.05\r\nR = 287.05u\"J/(kg * K)\"\r\nT = (300 ± 20)u\"K\"\r\n\r\nThe actual simulation is quite simple. The basic idea is that using the current pressure, you can calculate \\(\\dot{m}\\), which allows calculating the Thrust, and then you can subtract the current mass of air in the tank by \\(\\dot{m}\\) and recalculate pressure using the new mass then repeat the whole process.\r\nThe bulk of the equations in the simulation came from (Çengel and Boles 2015), while the Thrust and \\(v_e\\) equations came from (Sutton and Biblarz 2001, eq: 2-14).\r\n\\[ T = \\dot{m} \\cdot v_\\text{Exit} + A_\\text{Nozzle} \\cdot (P - P_\\text{Ambient}) \\]\r\nThe initial pressure difference is 4190.0 ± 300.0 psi, which is massive, so the area of the nozzle significantly alters the thrust profile. The paintball tanks come with pressure regulators, in our case, 800 psi which is still a huge number compared to atmospheric pressure. While the total impulse of the system doesn’t change with different nozzle areas, the peak thrust and burn time vary greatly. One of the benefits of doing air propulsion and the reason it was even considered so seriously is that it should be possible to change the nozzle diameter in flight, allowing thrust to be throttled, making controlled landing easier to control.\r\n\r\ndf = let\r\nt = 0.0u\"s\"\r\nP = P0 |> u\"Pa\"\r\nM = V * (P / (R * T)) |> u\"kg\"\r\nts = 1u\"ms\"\r\ndf = DataFrame(Thrust=(0 ± 0)u\"N\", Pressure=P0, Time=0.0u\"s\", Mass=M)\r\n while M > 0.005u\"kg\"\r\n # Calculate what is leaving tank\r\n P = minimum([P, Pmax])\r\n ve = sqrt((2 * γ / (γ - 1)) * R * T * (1 - P_amb / P)^((γ - 1) / γ)) |> u\"m/s\"\r\n ρ = P / (R * T) |> u\"kg/m^3\"\r\n ṁ = ρ * a_nozzle * ve |> u\"kg/s\"\r\n \r\n Thrust = ṁ * ve + a_nozzle * (P - P_amb) |> u\"N\"\r\n \r\n # Calculate what is still in the tank\r\n M = M - ṁ * ts |> u\"kg\"\r\n P = (M * R * T) / V |> u\"Pa\"\r\n t = t + ts\r\n \r\n df_step = DataFrame(Thrust=Thrust, Pressure=P, Time=t, Mass=M)\r\n append!(df, df_step)\r\n end\r\n df\r\nend\r\n\r\nAnalysis\r\nBelow in figure 1, the result of the simulation is plotted. Notice the massive error once the tank starts running low. This is because the calculation for pressure has a lot of very uncertain variables. This is primarily due to air being a compressible fluid, making this simulation challenging to do accurately. The thrust being below 0 N might not make intuitive sense, but it’s technically possible for the pressure to compress, leaving the inside of the rocket nozzle with a pressure that’s actually below atmospheric pressure. The effect would likely last a fraction of a second, but the point stands that this simulation is wildly inaccurate and only meant to get an idea of what an air propulsion system is capable of.\r\n\r\n\r\nShow code\r\n\r\nthrust_values = df.Thrust .|> ustrip .|> value;\r\nthrust_uncertainties = df.Thrust .|> ustrip .|> uncertainty;\r\n\r\nair = DataFrame(Thrust=thrust_values, Uncertainty=thrust_uncertainties, Time=df.Time .|> u\"s\" .|> ustrip);\r\n\r\n\r\nplot(df.Time .|> ustrip, thrust_values, \r\n title=\"Thrust Over Time\", \r\n ribbon=(thrust_uncertainties, thrust_uncertainties), \r\n fillalpha=.2,label=\"Thrust\",\r\n xlabel=\"Time (s)\", \r\n ylabel=\"Thrust (N)\",\r\n )\r\n\r\n\r\nFigure 1: Air Proplsion Simulation\r\n\r\n\r\n\r\nIn Figure 2, the air propulsion simulation is compared to commercially available rocket motors. This early in the project, we have no idea whether short burns or longer burns are ideal for a propulsive landing, so the air propulsion system was compared to a variety of different motors with unique profiles.\r\n\r\n\r\nShow code\r\n\r\nf10 = CSV.read(\"AeroTech_F10.csv\", DataFrame);\r\nf15 = CSV.read(\"Estes_F15.csv\", DataFrame);\r\ng8 = CSV.read(\"AeroTech_G8ST.csv\", DataFrame);\r\n\r\n\r\nplot(air.Time, air.Thrust, label=\"Air Propulsion\", legend=:topleft);\r\n\r\nfor (d, l) in [(f10, \"F10\"), (f15, \"F15\"), (g8, \"G8ST\")]\r\n plot!(d[!,\"Time (s)\"], d[!, \"Thrust (N)\"], label=l);\r\nend\r\n\r\ntitle!(\"Propulsion Comparison\");\r\nxlabel!(\"Time (s)\");\r\nylabel!(\"Thrust (N)\")\r\n\r\n\r\nFigure 2: Rocket Motor Data: (Coker, n.d.)\r\n\r\n\r\n\r\nIn the end, the air propulsion system’s performance has a very impressive total impulse and, with more time and resources, could be a serious option for a propulsive landing on Earth. One of the largest abstractions from the Moon mission that the mission here on Earth will have to deal with is the lack of Throttling engines since any propulsion system outside of model rocket motors is well beyond the scope of this Capstone.\r\nFuture Work\r\nAfter determining that solid model rocket motors are the best option for the current mission scope, the next step is determining what motor to use. There are many great options, and deciding what thrust profile is ideal may have to wait until a Simulink simulation of the landing can be built so that the metrics of each motor can be constrained more. Instead of throttling motors, the current working idea is that thrust vector control may be a way to squeeze a little more control out of a solid rocket motor. Thrust Vector Control will undoubtedly be challenging to control, so another essential piece that needs exploring is whether an LQR controller is feasible or if a PID controller is accurate enough to control our system.\r\n\r\n\r\n\r\nCoker, John. n.d. “Rocket Motor Data.” https://www.thrustcurve.org/.\r\n\r\n\r\nÇengel, Yunus A., and Michael A. Boles. 2015. Thermodynamics: An Engineering Approach. Eighth edition. New York: McGraw-Hill Education.\r\n\r\n\r\nSutton, George P., and Oscar Biblarz. 2001. Rocket Propulsion Elements. 7th ed. New York: John Wiley & Sons.\r\n\r\n\r\n\r\n\r\n",
|
||
"preview": "posts/2021-04-01-air-propulsion-simulation/air-propulsion-simulation_files/figure-html5/unnamed-chunk-7-J1.png",
|
||
"last_modified": "2021-08-24T06:53:55+00:00",
|
||
"input_file": {},
|
||
"preview_width": 600,
|
||
"preview_height": 400
|
||
}
|
||
]
|