Git Product home page Git Product logo

temperaturemodel's Introduction

TemperatureModel

Parker Smith

The purpose of this code is to calculate a prediction for the internal temperatures of a surface with heat applied to its edges. The code will first set the global variables for maximum values (rows as 26 and columns as 30). The code then initializes the functions using function prototypes. As the program moves into the main function, it will create a two-dimensional array and prompt the user to enter the dimensions of the array, using while loops to ensure the values are within the required parameters (if it is below 3, the function will not run correctly because there are no "interior" tiles). Main then prompts the user to input temperatures along each edge (top, left, right, bottom), and the value for epsilon (epsilon is the variable name used to describe the change in temperatures of each tile in between iterations. It will essentially tell your code when to end since it will end once the change in temperature of all tiles is less than epsilon). These values are all called to function "value_check", which will use a while function to ensure the value is within the parameters (0 and 300). These values are returned by reference. After main has all its variables, it will function call "initial".

In the initial function, the array will be initialized and filled with zeroes. This is important because if the array isn't initialized, the code has problems calculating the first averages. The code fills the array with zeroes by doing a for nested within a for that will cycle through every column and row and set the value equal to zero. The code will then do the first iteration. Again, this is done by using the nested for to set the corner values and then moving into the interior tiles. The code sets averages by getting the values all around the current tile and dividing it by two. IMPORTANT NOTE- The code will average from the top left corner to the bottom right corner. This means that the code will only use the values to the left and above since the other two values will be zero.This will slightly affect the values within the array, but in the final iteration, the values should essentially even out. The code outputs this array and labels it original array, then ends. The array is automatically stored by reference.

Main then calls the function "inside_rows". This works similarly to the previous function, using a nested for to cycle through all the values of the array (besides the edge tiles, since those are considered constant). It then finds the values of the four surrounding values for each tile and divides them by 4 to find the new temperature. The code will then calculate the change in temperature for each value. If it is greater than epsilon, a test variable is set to 1. If any value is greater than epsilon, the loop runs again. If all values are less than epsilon, the loop will end because the value will stay at zero (The entire loop is contained in a do while, so a non "1" value will end the loop. The code will then output the array at the end of each iteration, regardless of the outcome. The final iteration will be the equilibrium of the tiles.

temperaturemodel's People

Contributors

p-smith22 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.