import 'package:flutter/material.dart'; class EnergyModelProvider with ChangeNotifier { double potentialEnergy = 0, kineticEnergy = 0, energyInJoule = 0, literWaterToHeat = 0, kilogrammIronToHeat = 0; EnergyModelProvider() {} /// E = kg * (m^2 / s^2) double calculateEnergyInJoule(String weightValue, String velocity) { double weightValueInDouble = double.parse(weightValue); double velocityInDouble = double.parse(velocity); energyInJoule = (velocityInDouble * velocityInDouble) / weightValueInDouble; notifyListeners(); return energyInJoule; } /// E = m * g * h in Joule void calculateEnergyPotential(String weightValue, String altitudeChange) { double weightValueInDouble = double.parse(weightValue); double altitudeChangeInDouble = double.parse(altitudeChange); potentialEnergy = weightValueInDouble * 9.81 * altitudeChangeInDouble; notifyListeners(); } /// E = 1/2 * m * v^2 in Joule void calculateEnergyKinetic(String weightValue, String velocity) { double weightValueInDouble = double.parse(weightValue); double velocityInDouble = double.parse(velocity); kineticEnergy = 0.5 * weightValueInDouble * (velocityInDouble * velocityInDouble); notifyListeners(); } /** * E = c * m * delta T * c = spezifische Wärmekapazität Wasser 4,182 kJ/l * m = Masse * delta T = Temperaturunterschied */ void calculateLiterToHeatWater() { // 4182 J = 1l = 1000kg Waasser um 1° zu erwaermen // E/c/delta T = m //Total Energie = Potentielle Energie + Kinetische Energie literWaterToHeat = (potentialEnergy + kineticEnergy) / (4182 * 80); notifyListeners(); } void calculateKgToHeatIron() { kilogrammIronToHeat = (potentialEnergy + kineticEnergy) / (460 * 680); notifyListeners(); } }