private void MakeHeating([NotNull] CalcHouseDto house, [NotNull] CalcHouse calchouse, [NotNull] HouseholdKey householdKey, [NotNull][ItemNotNull] List <CalcLocation> locations) //, List<CalcDeviceTaggingSet> deviceTaggingSets) { if (house.SpaceHeating == null) { return; } var heating = house.SpaceHeating; //var isNan = false; foreach (var degreeHour in heating.CalcDegreeDays) { if (double.IsNaN(degreeHour.HeatingAmount)) { throw new LPGException( "Heating degree days contain not-a-number. Check the temperature profile and your space heating settings."); } } var degreeDayDict = new Dictionary <Tuple <int, int, int>, CalcDegreeDay>(); foreach (var degreeDay in heating.CalcDegreeDays) { var cdd = new CalcDegreeDay { HeatingAmount = degreeDay.HeatingAmount, Year = degreeDay.Year, Month = degreeDay.Month, Day = degreeDay.Day }; degreeDayDict.Add(new Tuple <int, int, int>(cdd.Year, cdd.Month, cdd.Day), cdd); } var load = heating.PowerUsage[0]; var lt = _ltDict.GetLoadtypeByGuid(load.LoadTypeGuid); var cdl = new CalcDeviceLoad(lt.Name, load.MaxPower, lt, load.AverageYearlyConsumption, load.PowerStandardDeviation); var cdls = new List <CalcDeviceLoad> { cdl }; var heatloc = locations.Single(x => heating.CalcLocationGuid == x.Guid); CalcDeviceDto calcDeviceDto = new CalcDeviceDto("Space Heating", Guid.NewGuid().ToStrGuid(), householdKey, OefcDeviceType.SpaceHeating, "Space Heating", string.Empty, Guid.NewGuid().ToStrGuid(), heatloc.Guid, heatloc.Name); var csh = new CalcSpaceHeating(cdls, degreeDayDict, heatloc, calcDeviceDto, _calcRepo); //foreach (var calcDeviceTaggingSet in taggingSets) { //calcDeviceTaggingSet.AddTag("Space Heating","House Device"); //} calchouse.SetSpaceHeating(csh); //,deviceTaggingSets }
private void SetAirConditioningOnHouse([NotNull] CalcHouseDto house, [NotNull] CalcHouse calcHouse, [NotNull][ItemNotNull] List <CalcLocation> calcLocations) { if (house.AirConditioning == null) { return; } var acdto = house.AirConditioning; var degreeHourDict = new Dictionary <Tuple <int, int, int, int>, CalcDegreeHour>(); foreach (CalcDegreeHourDto dto in acdto.CalcDegreeHours) { degreeHourDict.Add(new Tuple <int, int, int, int>(dto.Year, dto.Month, dto.Day, dto.Hour), new CalcDegreeHour(dto.Year, dto.Month, dto.Day, dto.Hour, dto.CoolingAmount)); } //var isNan = false; foreach (var degreeHour in degreeHourDict.Values) { if (double.IsNaN(degreeHour.CoolingAmount)) { throw new LPGException("Cooling degree hour was not-a-number. Check the air conditioning and temperature profile."); } } var deviceLoad = acdto.DeviceLoads[0]; var loadtype = _ltDict.GetLoadtypeByGuid(deviceLoad.LoadTypeGuid); var cdl = new CalcDeviceLoad(deviceLoad.Name, deviceLoad.MaxPower, loadtype, deviceLoad.AverageYearlyConsumption, deviceLoad.PowerStandardDeviation); var cdls = new List <CalcDeviceLoad> { cdl }; var acloc = calcLocations.Single(x => x.Guid == acdto.CalcLocationGuid); CalcDeviceDto acDevdto = new CalcDeviceDto("Air Conditioning", Guid.NewGuid().ToStrGuid(), house.HouseKey, OefcDeviceType.AirConditioning, "Air Conditioning", string.Empty, Guid.NewGuid().ToStrGuid(), acloc.Guid, acloc.Name); var csh = new CalcAirConditioning( cdls, degreeHourDict, acloc, acDevdto, _calcRepo); calcHouse.SetAirConditioning(csh); }
private List <CalcAutoDev> MakeCalcAutoDevsFromHouse([NotNull] CalcHouseDto house, [NotNull][ItemNotNull] List <CalcLocation> houseLocations) { var autodevs = new List <CalcAutoDev>(house.AutoDevs.Count); // zur kategorien zuordnung foreach (var hhautodev in house.AutoDevs) { CalcProfile calcProfile = CalcDeviceFactory.MakeCalcProfile(hhautodev.CalcProfile, _calcRepo.CalcParameters); CalcLoadType clt = _ltDict.GetLoadtypeByGuid(hhautodev.LoadtypeGuid); List <CalcDeviceLoad> loads = new List <CalcDeviceLoad>(); foreach (CalcDeviceLoadDto loadDto in hhautodev.Loads) { CalcDeviceLoad load = new CalcDeviceLoad(loadDto.Name, loadDto.MaxPower, _ltDict.GetLoadtypeByGuid(loadDto.LoadTypeGuid), loadDto.AverageYearlyConsumption, loadDto.PowerStandardDeviation); loads.Add(load); } List <VariableRequirement> requirements = new List <VariableRequirement>(); foreach (var reqDto in hhautodev.Requirements) { VariableRequirement rq = new VariableRequirement(reqDto.Name, reqDto.Value, reqDto.CalcLocationName, reqDto.LocationGuid, reqDto.VariableCondition, _variableRepository, reqDto.VariableGuid); requirements.Add(rq); } CalcLocation houseLocation = houseLocations.Single(x => x.Guid == hhautodev.CalcLocationGuid); var cautodev = new CalcAutoDev( calcProfile, clt, loads, hhautodev.TimeStandardDeviation, hhautodev.Multiplier, houseLocation, requirements, hhautodev, _calcRepo); var busyarr = _availabilityDtoRepository.GetByGuid(hhautodev.BusyArr.Guid); cautodev.ApplyBitArry(busyarr, _ltDict.GetLoadtypeByGuid(hhautodev.LoadtypeGuid)); autodevs.Add(cautodev); } return(autodevs); }
private void MakeAllTransformationDevices([NotNull] CalcHouseDto house, [NotNull] CalcHouse calchouse, [NotNull] HouseholdKey householdKey) //List<CalcDeviceTaggingSet> taggingSets, { var ctds = new List <CalcTransformationDevice>(); var devcategoryGuid = Guid.NewGuid().ToStrGuid(); var trafolocGuid = Guid.NewGuid().ToStrGuid(); foreach (var trafo in house.TransformationDevices) { foreach (var set in _calcDeviceTaggingSets.AllCalcDeviceTaggingSets) { set.AddTag(trafo.Name, "House Device"); } CalcDeviceDto cdd = new CalcDeviceDto(trafo.Name, devcategoryGuid, householdKey, OefcDeviceType.Transformation, "Transformation Devices", "", trafo.Guid, trafolocGuid, "Transformation Devices"); var ctd = new CalcTransformationDevice(_calcRepo.Odap, trafo.MinValue, trafo.MaxValue, trafo.MinPower, trafo.MaxPower, cdd, _ltDict.GetLoadtypeByGuid(trafo.InputLoadType.Guid)); foreach (var outlt in trafo.OutputLoadTypes) { ctd.AddOutputLoadType(_ltDict.GetLoadtypeByGuid(outlt.LoadType.Guid), outlt.ValueScalingFactor, outlt.FactorType); } if (ctd.OutputLoadTypes.Count > 0) { if (trafo.Datapoints != null) { foreach (var datapoint in trafo.Datapoints) { ctd.AddDatapoint(datapoint.Ref, datapoint.Val); } } foreach (var condition in trafo.Conditions) { var variable = _variableRepository.GetVariableByGuid(condition.CalcVariableDto.Guid); ctd.AddCondition(condition.Name, variable, condition.MinValue, condition.MaxValue, condition.Guid); } ctds.Add(ctd); } } calchouse.SetTransformationDevices(ctds); }
public CalcHouse MakeCalcHouse([NotNull] CalcHouseDto calcHouseDto, CalcRepo calcRepo) { HouseholdKey houseKey = Constants.HouseKey; var calchouse = new CalcHouse(calcHouseDto.HouseName, calcHouseDto.HouseKey, calcRepo); List <CalcLocation> houseLocations = new List <CalcLocation>(); foreach (var houseLoc in calcHouseDto.HouseLocations) { CalcLocation cl = new CalcLocation(houseLoc.Name, houseLoc.Guid); houseLocations.Add(cl); } var calcAbleObjects = new List <ICalcAbleObject>(); //var globalLocationDict = new Dictionary<CalcLocationDto, CalcLocation>(); foreach (var householddto in calcHouseDto.Households) { var hh = _cmhf.MakeCalcModularHousehold(householddto, out var _, calcHouseDto.HouseName, calcHouseDto.Description, _calcRepo); calcAbleObjects.Add(hh); // foreach (var pair in dtoCalcLocationDict.LocationDtoDict) { // if (!globalLocationDict.ContainsKey(pair.Key)) { // globalLocationDict.Add(pair.Key, pair.Value); // } //} } calchouse.SetHouseholds(calcAbleObjects); MakeHeating(calcHouseDto, calchouse, houseKey, houseLocations); //, taggingSets); SetAirConditioningOnHouse(calcHouseDto, calchouse, houseLocations); var autodevs2 = MakeCalcAutoDevsFromHouse(calcHouseDto, houseLocations); calchouse.SetAutoDevs(autodevs2); // energy Storage SetEnergyStoragesOnHouse(calcHouseDto.EnergyStorages, houseKey, calchouse, _variableRepository); //, taggingSets); // transformation devices MakeAllTransformationDevices(calcHouseDto, calchouse, houseKey); //taggingSets, // generators calchouse.SetGenerators(MakeGenerators(calcHouseDto.Generators, houseKey)); //taggingSets, return(calchouse); }
public CalcHouseDto MakeHouseDto([NotNull] Simulator sim, [NotNull] House house, [NotNull] TemperatureProfile temperatureProfile, [NotNull] GeographicLocation geographicLocation, //List<CalcDeviceTaggingSet> taggingSets, EnergyIntensityType energyIntensity) { if (house.HouseType == null) { throw new LPGException("Housetype was null"); } if (energyIntensity == EnergyIntensityType.AsOriginal) { energyIntensity = house.EnergyIntensityType; } if (energyIntensity == EnergyIntensityType.AsOriginal) { var calcObject = house.Households[0].CalcObject; if (calcObject == null) { throw new LPGException("House was null"); } energyIntensity = calcObject.EnergyIntensityType; } var houseLocations = new List <CalcLocationDto>(); HouseholdKey houseKey = Constants.HouseKey; List <DeviceCategoryDto> deviceCategoryDtos = new List <DeviceCategoryDto>(); foreach (var deviceCategory in sim.DeviceCategories.It) { deviceCategoryDtos.Add(new DeviceCategoryDto(deviceCategory.FullPath, Guid.NewGuid().ToStrGuid())); } HouseIntegrityChecker.Run(house, sim); var householdIndex = 1; var calcAbleObjects = new List <CalcHouseholdDto>(); var globalLocationDict = new Dictionary <Location, CalcLocationDto>(); foreach (var household in house.Households) { if (household.CalcObject == null) { throw new LPGException("Calcobject was null"); } if (household.CalcObject.CalcObjectType == CalcObjectType.ModularHousehold) { CalcHouseholdDto hhdto = _hhDtoFactory.MakeCalcModularHouseholdDto(sim, (ModularHousehold)household.CalcObject, temperatureProfile, new HouseholdKey("HH" + householdIndex), geographicLocation, out var locationDtoDict, household.TransportationDeviceSet, household.TravelRouteSet, energyIntensity, household.ChargingStationSet); calcAbleObjects.Add(hhdto); foreach (var pair in locationDtoDict.LocationDict) { if (!globalLocationDict.ContainsKey(pair.Key)) { globalLocationDict.Add(pair.Key, pair.Value); } } } else { throw new LPGException("Unknown Calc Object Type in the house! This is a bug."); } householdIndex++; } var spaceHeating = CreateSpaceHeatingObject(house, temperatureProfile, houseKey, out var heatingLocation, _calcParameters.InternalStartTime, _calcParameters.InternalEndTime , _ltDict); //, taggingSets); if (heatingLocation != null) { houseLocations.Add(heatingLocation); } var airconditioning = MakeAirConditioning(temperatureProfile, house.HouseType, houseKey, out var airconditioningLocation); if (airconditioningLocation != null) { houseLocations.Add(airconditioningLocation); } List <CalcAutoDevDto> autoDevs = new List <CalcAutoDevDto>(); var autodevs2 = MakeCalcAutoDevsFromHouse(temperatureProfile, geographicLocation, house.HouseType.HouseDevices, energyIntensity, houseKey, house.Name, sim.DeviceActions.It, house, out var devLocations, deviceCategoryDtos); houseLocations.AddRange(devLocations); autoDevs.AddRange(autodevs2); // energy Storage var calcEnergyStorages = MakeEnergyStorages(house, houseKey); //, taggingSets); // transformation devices var transformationDevices = MakeAllTransformationDevices(house.HouseType, houseKey); //taggingSets, // generators var generators = MakeGenerators(house.HouseType.HouseGenerators.Select(x => x.Generator).ToList(), houseKey); //taggingSets, var calchouse = new CalcHouseDto(house.Name, autoDevs, airconditioning, spaceHeating, calcEnergyStorages, generators, transformationDevices, calcAbleObjects, houseKey, houseLocations, house.Description); //check the calc variables return(calchouse); }