Skip to content

Instantly share code, notes, and snippets.

@n7275
n7275 / FuelCellPerformance.m
Last active March 10, 2021 05:28
Model of Apollo Fuel Cell Performance as a function of Current and Temperature
clear;
clc;
close all;
V = zeros(100);
P = zeros(100);
ST = zeros(100);
H = zeros(100);
Hnet = zeros(100);
clear;
clc;
close all;
hold off;
dt = 1.19;
time = 50;
n_steps = round(time/dt);
%rendering of gravity model, Gapcynski et al., 1969
%coefficients taken from https://arc.aiaa.org/doi/10.2514/3.5479
clear;
clc;
close all;
resolution =75;
GM = 4902.58;
clear;
clc;
Temp = 477;
power_load = 2198;
A = 0.023951368224792 * Temp + 23.9241562583015;
B = 0.003480859912024 * Temp - 2.19986938582928;
C = -0.0001779207513 * Temp + 0.104916556604259;
D = 5.0656524872309E-06 * Temp - 0.002885372247954;
@n7275
n7275 / powermerge.m
Last active April 17, 2021 16:35
Powermerge Demo
##clear;
##clc;
powerdraw = 700; #nominal watts at 28V
RL = 28^2/powerdraw; %Load Resistance
R1 = 0.014; %Wire Resistance
R2 = 0.015; %Wire Resistance
R3 = 0.012; %Wire Resistance
R4 = 0.015; %Wire Resistance
%Van der Waals
clear;
clc;
Tvdw = linspace(0,3.5,150);
V = linspace(0.25,5,202);
[TT,VV] = meshgrid(Tvdw,V);
P = 8/3.*(TT./(VV-1/3))-3./(VV.^2);
clear;
clc;
pkg load symbolic;
sympref display unicode;
syms R0 R1 R2 R3 R4 R5 real;
syms V1 V2 V3 V4 V5 real;
ImpedanceMatrix5 = [R1+R0, -R1, 0, 0, 0;...
-R1, R1+R2, -R2, 0, 0;...
#include <iostream>
#include <cmath>
#include <mutex>
#include <thread>
#include <Windows.h>
void sinusoid(bool &die, double &t, double &val, std::mutex &m)
{
while (!die)
{
@n7275
n7275 / VDWSystemsTest.m
Created September 7, 2021 21:20
VDW Systems Test for NASSP
clear;
clc;
Temp = linspace(0,200,20);
R_CONST = 8314.4621;
MMASS = 31.998;
vapor_mass = linspace(0,300,20);
air_volume = 0.5;
a = 1.382/101300;
b = 0.03186;
#NASSP SPSDK Tank simulator;
#inital conditions are set up to demo a CSM O2 Tank
clear all;
clc;
close all;
n_itterations = 1000;
itteration = 0;
global delta_time = 0.01;