private static CalcRepo PrepareCalculation([NotNull] Simulator sim, [NotNull] CalcStartParameterSet csps, [NotNull] ILifetimeScope scope, [NotNull] out CalcLoadTypeDtoDictionary dtoltdict, [NotNull] out DayLightStatus dls, [NotNull] out CalcVariableRepository variableRepository ) { CalcRepo calcRepo = scope.Resolve <CalcRepo>(); var inputDataLogger = scope.Resolve <IInputDataLogger>(); inputDataLogger.Save(Constants.GeneralHouseholdKey, calcRepo.CalcParameters); inputDataLogger.Save(Constants.GeneralHouseholdKey, csps.TemperatureProfile); dtoltdict = scope.Resolve <CalcLoadTypeDtoDictionary>(); var affordanceTaggingSetFactory = scope.Resolve <AffordanceTaggingSetFactory>(); var affordanceTaggingSets = affordanceTaggingSetFactory.GetAffordanceTaggingSets(sim); if (calcRepo.CalcParameters.Options.Contains(CalcOption.AffordanceTaggingSets)) { inputDataLogger.Save(affordanceTaggingSets); } calcRepo.FileFactoryAndTracker.RegisterGeneralHouse(); dls = scope.Resolve <DayLightStatus>(); if (calcRepo.CalcParameters.Options.Contains(CalcOption.DaylightTimesList)) { inputDataLogger.Save(Constants.GeneralHouseholdKey, dls); } variableRepository = scope.Resolve <CalcVariableRepository>(); return(calcRepo); }
public static CalcLoadTypeDictionary MakeLoadTypes( [NotNull] CalcLoadTypeDtoDictionary dtoDict) { var ltDict = new Dictionary <CalcLoadTypeDto, CalcLoadType>(); foreach (var dto in dtoDict.Ltdtodict.Values) { var calcLoadType = new CalcLoadType(dto.Name, dto.UnitOfPower, dto.UnitOfSum, dto.ConversionFactor, dto.ShowInCharts, dto.Guid); ltDict.Add(dto, calcLoadType); } return(new CalcLoadTypeDictionary(ltDict)); }
private static CalcSpaceHeatingDto MakeSpaceHeatingDto([NotNull] HeatingParameter heatingparameter, [NotNull] CalcLoadTypeDtoDictionary ltDict, [NotNull] HouseholdKey householdKey, [CanBeNull] out CalcLocationDto heatingLocation) //, List<CalcDeviceTaggingSet> taggingSets) { if (!ltDict.SimulateLoadtype(heatingparameter.HeatingLoadType)) { heatingLocation = null; return(null); } var degreeDayDict = new List <CalcDegreeDayDto>(); foreach (var degreeDay in heatingparameter.DegreeDays) { var cdd = new CalcDegreeDayDto(degreeDay.Date.Year, degreeDay.Date.Month, degreeDay.Date.Day, degreeDay.HeatingAmount); degreeDayDict.Add(cdd); } var lt = ltDict.GetLoadtypeDtoByLoadType(heatingparameter.HeatingLoadType); var cdl = new CalcDeviceLoadDto(heatingparameter.HeatingLoadType.Name, -1, lt.Name, lt.Guid, heatingparameter.YearlyConsumption, 0, Guid.NewGuid().ToStrGuid(), 1); var cdls = new List <CalcDeviceLoadDto> { cdl }; heatingLocation = new CalcLocationDto("Space Heating Location", -102, Guid.NewGuid().ToStrGuid()); var csh = new CalcSpaceHeatingDto("Space Heating", -1, cdls, degreeDayDict, householdKey, heatingLocation.Name, heatingLocation.Guid, Guid.NewGuid().ToStrGuid()); //foreach (var calcDeviceTaggingSet in taggingSets) { //calcDeviceTaggingSet.AddTag("Space Heating","House Device"); //} return(csh); }
public CalcHouseDtoFactory([NotNull] CalcLoadTypeDtoDictionary ltDict, [NotNull] Random random, [NotNull] IDeviceCategoryPicker picker, [NotNull] CalcParameters calcParameters, [NotNull] CalcModularHouseholdDtoFactory hhDtoFactory, [NotNull] AvailabilityDtoRepository availabilityDtoRepository, [NotNull] CalcVariableDtoFactory calcVariableDtoFactory) { _ltDict = ltDict; _random = random; _picker = picker; _calcParameters = calcParameters; _hhDtoFactory = hhDtoFactory; _availabilityDtoRepository = availabilityDtoRepository; _calcVariableDtoFactory = calcVariableDtoFactory; }
public static CalcSpaceHeatingDto CreateSpaceHeatingObject([NotNull] House house, [NotNull] TemperatureProfile temperatureProfile, [NotNull] HouseholdKey householdKey, [CanBeNull] out CalcLocationDto heatingLocation, DateTime startTime, DateTime endTime, CalcLoadTypeDtoDictionary ltDict) //, List<CalcDeviceTaggingSet> deviceTaggingSets) { if (house.HouseType == null) { throw new LPGException("Housetype was null"); } if (house.HouseType.HeatingLoadType != null && Math.Abs(house.HouseType.HeatingYearlyTotal) > 0.0001 && !double.IsNaN(house.HouseType.HeatingYearlyTotal)) { var degreeDays = MakeDegreeDaysClass.MakeDegreeDays(temperatureProfile, startTime, endTime, house.HouseType.HeatingTemperature, house.HouseType.RoomTemperature, house.HouseType.HeatingYearlyTotal, house.HouseType.AdjustYearlyEnergy, house.HouseType.ReferenceDegreeDays); foreach (var degreeHour in degreeDays) { if (double.IsNaN(degreeHour.HeatingAmount)) { throw new LPGException("Heating Amount was NaN"); } } var heatingParameter = new HeatingParameter(degreeDays, house.HouseType.HeatingLoadType, house.HouseType.HeatingYearlyTotal); var spaceheating = MakeSpaceHeatingDto(heatingParameter, ltDict, householdKey, out heatingLocation); return(spaceheating); //,deviceTaggingSets } heatingLocation = null; return(null); }
private static List <CalcEnergyStorageDto> CreateEnergyStorageDtos([NotNull][ItemNotNull] List <EnergyStorage> energyStorages, [NotNull] CalcLoadTypeDtoDictionary ltdict, [NotNull] HouseholdKey householdKey, CalcVariableDtoFactory calcVariableDtoFactory) { var calcEnergyStorages = new List <CalcEnergyStorageDto>(); foreach (var es in energyStorages) { if (es.LoadType == null) { throw new LPGException("Energy storage load type was null"); } if (ltdict.SimulateLoadtype(es.LoadType)) { List <CalcEnergyStorageSignalDto> signals = new List <CalcEnergyStorageSignalDto>(); foreach (var signal in es.Signals) { if (signal.Variable == null) { throw new DataIntegrityException("Signal variable was null"); } var cvdto = calcVariableDtoFactory.RegisterVariableIfNotRegistered(signal.Variable, "House", Constants.HouseLocationGuid, Constants.HouseKey); var cessig = new CalcEnergyStorageSignalDto(signal.Name, signal.IntID, signal.TriggerLevelOff, signal.TriggerLevelOn, signal.Value, cvdto, Guid.NewGuid().ToStrGuid()); signals.Add(cessig); } //foreach (DeviceTaggingSet set in deviceTaggingSets) { //set.AddTag(es.Name,"House Device"); //} var lt = ltdict.GetLoadtypeDtoByLoadType(es.LoadType); var ces = new CalcEnergyStorageDto(es.Name, es.IntID, lt, es.MaximumStorageRate, es.MaximumWithdrawRate, es.MinimumStorageRate, es.MinimumWithdrawRate, es.InitialFill, es.StorageCapacity, householdKey, Guid.NewGuid().ToStrGuid(), signals); calcEnergyStorages.Add(ces); if (es.Signals.Count != ces.Signals.Count) { throw new LPGException("Signals for energy storage were not correctly initialized"); } } else { throw new DataIntegrityException("You are trying to run a calculation with a house type that uses an energy storage, " + " that references an load type you excluded. This will not work. Please enable the load type " + es.LoadType + " by for example chosing All Loadtypes"); } } return(calcEnergyStorages); }
public CalcTransportationDtoFactory([NotNull] CalcLoadTypeDtoDictionary loadTypeDict) { _loadTypeDict = loadTypeDict; }