cpd_2022_energy/lib/models/EnergyBilanceModel.dart

58 lines
1.6 KiB
Dart
Raw Normal View History

2022-11-07 18:52:21 +01:00
import 'dart:math';
import 'package:flutter/material.dart';
class EnergyBilanceModel extends ChangeNotifier {
double _startVelocity = 0;
double _endVelocity = 0;
double _startHeight = 0;
double _endHeight = 0;
double _weight = 0;
2022-11-07 22:12:21 +01:00
final double _gravity = 9.81; //in m/s^2
2022-11-08 22:23:56 +01:00
final double _waterHeatCapacity = 4181; //J / (kg * C°)
final double _ironHeatCapacity = 439; //in J / (kg * C°)
2022-11-07 22:12:21 +01:00
double _waterTemparatureStart = 20; //in °C
final int _temparatureToBoilWater = 100; //in °C
double _ironTemparatureStart = 20; //in °C
final int _temparatureToMakeIronGlow = 700; //in °C
2022-11-07 18:52:21 +01:00
double get deltaVelocity => _endVelocity - _startVelocity;
double get deltaHeight => _endHeight - _startHeight;
2022-11-07 22:12:21 +01:00
double get potentialEnergy => _weight * _gravity * deltaHeight; //in Joule = m^2 kg/s^2
2022-11-07 18:52:21 +01:00
double get kineticEnergy => _weight * pow(deltaVelocity, 2) / 2;
2022-11-08 22:23:56 +01:00
double get amountOfBoilingWaterInL => (((potentialEnergy + kineticEnergy) / _waterHeatCapacity) / (_temparatureToBoilWater - _waterTemparatureStart)); //in litre
double get amountOfGlowingIronInKg => (((potentialEnergy + kineticEnergy) / _ironHeatCapacity) / (_temparatureToMakeIronGlow - _ironTemparatureStart)); //in kg
2022-11-07 22:12:21 +01:00
2022-11-07 18:52:21 +01:00
void setStartVelocity(double v){
_startVelocity = v;
notifyListeners();
}
void setEndVelocity(double v){
_endVelocity = v;
notifyListeners();
}
void setStartHeight(double h){
_startHeight = h;
notifyListeners();
}
void setEndHeight(double h){
_endHeight = h;
notifyListeners();
}
void setWeight(double m){
_weight = m;
notifyListeners();
}
}