Skip to content

Instantly share code, notes, and snippets.

@teejayvanslyke
Forked from anonymous/gist:238486
Created November 19, 2009 02:27
Show Gist options
  • Save teejayvanslyke/238487 to your computer and use it in GitHub Desktop.
Save teejayvanslyke/238487 to your computer and use it in GitHub Desktop.
/*Adam VanSlyke
adamvans
11/18/2009
PA4
Ellen Cardone
A3
I have prepared this assignment on my own and understand the consequences of copying other people's work.
*/
using namespace std;
#include<iostream>
#include<cmath>
#include<fstream>
#include<iomanip>
void dTdt(double, double, double);
int main()
{
double m[4], TF[4], delt;
int i;
ifstream datain("heatdata.txt");
char line[100];
datain.getline(line,100);
cout<<"Enter a time step size: ";
cin>>delt;
for(i=0; i<=4; i++)
{
datain>>m[i]>>TF[i];
dTdt(m[i], TF[i], delt);
}
system("pause");
return 0;
}
void dTdt(double m, double TF, double delt)
{
double a=14.5, b=0.156, c=0.000025, k=998, totalt, T=25;
double Cp, Tnext;
for(totalt=0; totalt<500; totalt+delt)
{
do
{
Cp=a+b*T+c*pow(T,2);
Tnext=T+((k*(TF-T))/(0.9*m*Cp))*delt;
T=Tnext;
totalt += delt;
}
while (!T<TF);
}
cout<<T<<" "<<totalt<<" "<<TF<<endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment