-
-
Save teejayvanslyke/238487 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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