Page 1 of 1

A flexible calculation tool (part 1)

Posted: Mon Aug 26, 2024 10:59 am
by Henko
After buying a new car with a hybrid drive train, i made a calculation model for such kind of a car. There are many variables that influence the needed power and fuel at the various conditions. In this model each variable is represented by two buttons, the upper button with a description, the lower button with its value.
Both buttons are selectable. Touching a lower button enables changing the value of the variable. Touching the upper button tells the model to (try to) calculate the value of that variable, given the values of all the other variables, in other words: to solve the system for the selected variable.
IMG_1237.png
IMG_1237.png (152.23 KiB) Viewed 607 times
For instance, a (rather unrealistic) example: if we take one extra person (75 kg) in the car, and have to cope with a slope of +1%, then how much wind must we have in the back to maintain the same speed and range?
Entering a value of 160 in the “payload” variable and a value of 1 in the “slope%” variable, then touching the green “wind m/sec” button changes the value of the wind variable from 0 into 7,6 m/sec (=27 km/h).


Not all varables in the model are selectable, only the green ones. The other “variables are intermediate results or auxiliary values for readablility.

The model is coded as a framework for all kind of application. The user only has to specify the variables (name, position on the screen, initial value, selectability) and the calculation(s).

This car model is rather complex, i will explain the model (and provide the code) in the next post, using a simple, well known mechanism: an annuity loan.