### Logical Error somewhere?

During the initial period, when the heater is not yet functioning at peak efficiency the heating will increase the temperature inside the building at a rate given by the following equations. During the initial period when the air conditioner is not yet functioning at peak efficacy the air conditioner will decrease the temperature inside the building at a rate given by the same equations.

Interval = (Time since turning on / 2.0 ) - 3.0
Factor multiplying Temperature change per minute = exp( Interval) / ( 1 + exp(Interval) )
These equations can also be used after the heating or air conditioner reaches peak efficiency. These equations converge to 1, so after the heating or air conditioner reach peak efficiency these equations will always give a value of 1.
NOTE: the value of these equations needs to be multiplied by the RATE TEMPERATURE CHANGES. The RATE TEMPERATURE CHANGES is EITHER the change in temperature inside the building in degrees Celsius per minute caused by heat being extracted by the air conditioning OR the change in temperature inside the building in degrees Celsius per minute caused by the heat being generated by the heating .Temperature change in degrees per minute = Factor multiplying Temperature change per minute * RATE TEMPERATURE CHANGES

Temperature at end of this interval = Temperature at the start of the interval + temperature change due to heat escaping during the this interval + temperature change due to heat generated by the heating system during this interval + temperature change due to heat removed by the cooling system during this interval

i have a:
...rate of -.05 for heat escape w/o cooling or heating
...rate of 0.10 for heat escape w/ cooling
...rate of 0.125 for heat increase w/ heating
...Starting temp=38.00
...Time interval 3.50

i can't seem to find the temp at the ending interval?

this is what i tried doing:

 ```#include #include using namespace std; int main () { double intervals=0.00; double tempPerMin=0.00; double tempAtEnd=0.00; double naturalChange=0.00; double coolChange=0.00; double heatChange=0.00; intervals=(3.5/2.0)-3.0; tempPerMin=(exp(intervals))/(1+exp(intervals)); naturalChange=(-0.05)*tempPerMin*3.5; coolChange=(0.1)*(tempPerMin)*3.5; heatChange=(0.125)*(tempPerMin)*3.5; tempAtEnd=38.00+coolChange+naturalChange+heatChange; cout<

the temperature at the end of the interval is suppose to be 37.81 but i can't get the answer. I'm pretty sure this is a logical error from the equations i used but i can't seem to find it. Any hints?

Last edited on
Use a debugger to step through your code and see what each variable is at each step of the program. In the absence of a debugger, print each of the values (intervals, tempPerMinute, etc.) to see where the error is occurring. When you see a value that isn't what you expected, you will narrow down where to look for your error.

Edit:

Also, consider that during cooling, temperature should decrease. I suspect that your factor should be -0.10 for cooling.
Last edited on
 intervals looks wrong.

Maybe it is. I have no way of knowing whether it is or not. The program calculated it properly according to the requirements you gave in your original post. Maybe your requirements are wrong.

 the temperature at the end of the interval is suppose to be 37.81 ...

Why do you believe this to be the case? What supporting calculations do you have for this baseline case? You need to compare your computed results with your baseline calculations to figure out what's wrong. Go through them step-by-step until you see where your program deviates from the reference calculations.

From my perspective, the problem does not appear to be in your code, but in your understanding and interpretation of the requirements.
Topic archived. No new replies allowed.