From f1a79e41e184f032028e2ffd5b37c93260eff344 Mon Sep 17 00:00:00 2001 From: woheller69 Date: Thu, 13 Apr 2023 17:11:29 +0200 Subject: [PATCH] change some stuff from float to double --- .../java/org/woheller69/weather/SolarPowerPlant.java | 10 +++++----- .../org/woheller69/weather/database/CityToWatch.java | 12 ++++++------ .../weather_api/open_meteo/OMDataExtractor.java | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/woheller69/weather/SolarPowerPlant.java b/app/src/main/java/org/woheller69/weather/SolarPowerPlant.java index d893bc1..b6a6bca 100644 --- a/app/src/main/java/org/woheller69/weather/SolarPowerPlant.java +++ b/app/src/main/java/org/woheller69/weather/SolarPowerPlant.java @@ -40,7 +40,7 @@ public class SolarPowerPlant { } - public float getPower(double solarPowerNormal, double solarPowerDiffuse, long epochTimeSeconds, float ambientTemperature) { + public float getPower(double solarPowerNormal, double solarPowerDiffuse, long epochTimeSeconds, double ambientTemperature) { Instant i = Instant.ofEpochSecond(epochTimeSeconds); //currentTimeMillis is in GMT ZonedDateTime dateTime = ZonedDateTime.ofInstant(i, ZoneId.of("GMT")); @@ -73,8 +73,8 @@ public class SolarPowerPlant { } } - float totalRadiationOnCell = (float) (solarPowerNormal * efficiency + solarPowerDiffuse * diffuseEfficiency); //flat plate equivalent of the solar irradiance - float cellTemperature = calcCellTemperature(ambientTemperature,totalRadiationOnCell); + double totalRadiationOnCell = solarPowerNormal * efficiency + solarPowerDiffuse * diffuseEfficiency; //flat plate equivalent of the solar irradiance + double cellTemperature = calcCellTemperature(ambientTemperature,totalRadiationOnCell); double dcPower = totalRadiationOnCell * cellsEfficiency * (1+(cellTemperature - 25)*cellsTempCoeff) * cellsArea; @@ -83,11 +83,11 @@ public class SolarPowerPlant { return (float) acPower; } - public static float calcCellTemperature(float ambientTemperature, float totalIrradiance){ + public static double calcCellTemperature(double ambientTemperature, double totalIrradiance){ //models from here: https://www.scielo.br/j/babt/a/FBq5Pmm4gSFqsfh3V8MxfGN/ Photovoltaic Cell Temperature Estimation for a Grid-Connect Photovoltaic Systems in Curitiba //float cellTemperature = 30.006f + 0.0175f*(totalIrradiance-300f)+1.14f*(ambientTemperature-25f); //Lasnier and Ang Lasnier, F.; Ang, T. G. Photovoltaic engineering handbook, 1st ed.; IOP Publishing LTD: Lasnier, France, 1990; pp. 258. //float cellTemperature = ambientTemperature + 0.028f*totalIrradiance-1f; //Schott Schott, T. Operation temperatures of PV modules. Photovoltaic solar energy conference 1985, pp. 392-396. - float cellTemperature = ambientTemperature + 0.0342f*totalIrradiance; //Ross model: https://www.researchgate.net/publication/275438802_Thermal_effects_of_the_extended_holographic_regions_for_holographic_planar_concentrator + double cellTemperature = ambientTemperature + 0.0342f*totalIrradiance; //Ross model: https://www.researchgate.net/publication/275438802_Thermal_effects_of_the_extended_holographic_regions_for_holographic_planar_concentrator //assuming "not so well cooled" : 0.0342 return cellTemperature; } diff --git a/app/src/main/java/org/woheller69/weather/database/CityToWatch.java b/app/src/main/java/org/woheller69/weather/database/CityToWatch.java index bc68368..aef9b23 100644 --- a/app/src/main/java/org/woheller69/weather/database/CityToWatch.java +++ b/app/src/main/java/org/woheller69/weather/database/CityToWatch.java @@ -37,15 +37,15 @@ public class CityToWatch { this.id = id; this.cityId = cityId; this.cityName = cityName; - this.cellsMaxPower = 650; + this.cellsMaxPower = 650.0f; this.cellsArea = 3.18f; this.cellsEfficiency = 19.3f; this.cellsTempCoeff = -0.4f; - this.diffuseEfficiency = 40; - this.inverterPowerLimit = 600; - this.inverterEfficiency = 95; - this.azimuthAngle = 170; - this.tiltAngle = 90; + this.diffuseEfficiency = 40.0f; + this.inverterPowerLimit = 600.0f; + this.inverterEfficiency = 95.0f; + this.azimuthAngle = 170.0f; + this.tiltAngle = 90.0f; } diff --git a/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/OMDataExtractor.java b/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/OMDataExtractor.java index e04856b..712f1b5 100644 --- a/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/OMDataExtractor.java +++ b/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/OMDataExtractor.java @@ -78,16 +78,16 @@ public class OMDataExtractor implements IDataExtractor { IApiToDatabaseConversion conversion = new OMToDatabaseConversion(); - float ambientTemperature = 25; + double ambientTemperature = 25.0; for (int i = 0; i < timeArray.length(); i++) { HourlyForecast hourlyForecast = new HourlyForecast(); hourlyForecast.setTimestamp(System.currentTimeMillis() / 1000); if (timeArray!=null && !timeArray.isNull(i)) hourlyForecast.setForecastTime(timeArray.getLong(i)*1000L); - if (tempArray != null && !tempArray.isNull(i)) ambientTemperature = (float) tempArray.getDouble(i); + if (tempArray != null && !tempArray.isNull(i)) ambientTemperature = tempArray.getDouble(i); if (weathercodeArray!=null && !weathercodeArray.isNull(i)) hourlyForecast.setWeatherID(conversion.convertWeatherCategory(weathercodeArray.getString(i))); if (directRadiationArray!=null && !directRadiationArray.isNull(i)) hourlyForecast.setDirectRadiationNormal((float) directRadiationArray.getDouble(i)); if (diffuseRadiationArray!=null && !diffuseRadiationArray.isNull(i)) hourlyForecast.setDiffuseRadiation((float) diffuseRadiationArray.getDouble(i)); - hourlyForecast.setPower(spp.getPower(hourlyForecast.getDirectRadiationNormal(),hourlyForecast.getDiffuseRadiation(), timeArray.getLong(i)-1800 , ambientTemperature)); //use solar position 1/2h earlier for calculation of average power in preceding hour + hourlyForecast.setPower(spp.getPower(hourlyForecast.getDirectRadiationNormal(), hourlyForecast.getDiffuseRadiation(), timeArray.getLong(i)-1800, ambientTemperature)); //use solar position 1/2h earlier for calculation of average power in preceding hour hourlyForecasts.add(hourlyForecast); } return hourlyForecasts;