Application Programming Interface

einstein.modules.buildings – Buildings

synopsis:Functions and a class to get, create and manipulate buildings and their properties.
author:Jan Ries <jan.ries@energyxperts.net>
class einstein.modules.buildings.Building(name)

Bases: object

Represent a building in a project with all its properties.

deleteFromDB(projectId=None, ANo=None)

Delete the building with our name associated to the given project.

Parameters:
  • projectId – If None is given the projectId of the current project is used as a default.
  • ANo – number of the alternative proposal, defaults to the current propsal if None is given.
getHolidayPeriodList(building)

Return ordered list of HolidayPeriods.

Parameters:building – building pSQL object
Returns:list of datetime elements.
getProcessNames()

Return the names of the process that could be created if this building has the appropriate properties.

loadFromDB(projectId=None, ANo=None)

Load Building with our name associated with given projectId. If no alternative proposal number is given, then the current one is the default.

saveToDB(projectId, ANo=None, omitProcesses=False)

Save the building as part of the project whose is given.

Parameters:
  • projectId – the id of the project the building is part of.
  • ANo – the alternative proposal number, defaults to the current alternative proposal
  • omitProcesses – if True then no the processes are created, deleted or updated, which usually represent the demands of the building.
exception einstein.modules.buildings.BuildingNotFoundError

Bases: exceptions.Exception

No building with given name for project found in DB.

exception einstein.modules.buildings.ProjectBuildingsNotFoundError

Bases: exceptions.Exception

No building for project with given id found in DB.

einstein.modules.buildings.getBuildingNamesFromDB(projectId, ANo=None)

Retrieve all known building names for given projectId from data base.

Parameters:
  • projectId (Integer) – Id of project with buildings to look for.
  • ANo – number of the alternative proposal, defaults to the current propsal if None is given.
Returns:

All building names stored in data base for projectId.

Return type:

List of strings

einstein.modules.buildings.getBuildings(projectId, ANo=None)

Retrieve all buildings associated with the given projectId from the database.

Parameters:
  • projectId (Integer) – Id of the process whose buildings are to retrieved.
  • ANo – number of the alternative proposal, defaults to the current propsal if None is given.
Returns:

a list of all buildings in the project.

Return type:

a List of Building objects.

einstein.modules.profiles – Operation time of processes

synopsis:Running time profiles for processes
author:David Baehrens <david.baehrens@energyxperts.net>
exception einstein.modules.schedules.profiles.ProfileNotFoundError

Bases: exceptions.Exception

No profile found with given name.

exception einstein.modules.schedules.profiles.ProfileWithoutIntervalsError

Bases: exceptions.Exception

Profile has no running time intervals.

einstein.modules.schedules.profiles.WEEKDAYS = ('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday')

Weekday names in order.

class einstein.modules.schedules.profiles.WeeklyProfile(name, profile=None, weekday=None, id=None)

Bases: object

Daily intervals of running time during one week on selected weekdays.

Parameters:
  • name (String) – Unique name used for identification
  • profile (List of 3-tuples (start time, stop time, scale integer)) – Initial daily intervals, default: empty
  • weekday (Dictionary {<names from einstein.modules.profiles.WEEKDAYS> : <Booleans>}) – Initial selection of weekdays, default: all False
  • id (Integer) – The database id of the profile.
Returns:

Weekly profile instance

Return type:

einstein.modules.profiles.WeeklyProfile

addInterval(start, stop, scale)

Add an running time interval to profile instance.

Parameters:
  • start (time) – start time (inclusive)
  • stop (time) – stop time (inclusive)
  • scale (Integer) – percentage of operation relative to nominal load
Returns:

nothing

calculateGlobals()
clearIntervals()

Remove all running time intervals from profile instance.

Returns:nothing
deleteFromDB()

Remove profile from data base.

Returns:nothing
Raises einstein.modules.profiles.ProfileNotFoundError:
 No profile with our name found in data base.
getIntervalsString()

Retrieve a string representation of the interval ranges in the profile.

Returns:Enumeration of intervals
Return type:String
getProfile()

Retrieve the running time intervals of profile instance.

Returns:Running time intervals ordered by ascending start time.
Return type:List of 3-tuples (start time, stop time, scale integer)
getProfileString()

Retrieve a string representation of the profile weekday and interval ranges.

Returns:Weekday ranges followed by interval enumeration.
Return type:String
getSchedulingProcesses()

Retrieve processes using the profile in its schedules.

Returns:List of DB IDs from qprocessdata
Return type:List of Integer
getWeekdays()

Retrieve the weekdays of operation.

Returns:Weekdays of operation ordered as in einstein.modules.profiles.WEEKDAYS
Return type:List of Boolean
getWeekdaysString()

Retrieve a string representation of the weekday ranges in the profile.

Returns:Ranges of abbreviated weekdays
Return type:String
loadFromDB(id=None)

Retrieve daily intervals and selected weekdays from data base.

To load a weekly profile from the data base by name construct an empty instance with the name first, then call this method on it. To get the names of all profiles available in the data base use einstein.modules.profiles.getProfileNamesFromDB().

Returns:

nothing

Raises:
  • einstein.modules.profiles.ProfileNotFoundError – No profile with our name found in data base.
  • einstein.modules.profiles.ProfileWithoutIntervalsError – Profile with our name has no intervals in data base.
saveToDB()

Store profile to data base.

Returns:nothing
setAllWeekdays(value)

Specify whether to run on all weekdays.

Parameters:value (Boolean) – Run on all days?
setFriday(value)

Specify whether to run on Friday.

Parameters:value (Boolean) – Run on Friday?
setMonday(value)

Specify whether to run on Monday. :param value: Run on Monday? :type value: Boolean

setSaturday(value)

Specify whether to run on Saturday.

Parameters:value (Boolean) – Run on Saturday?
setSunday(value)

Specify whether to run on Sunday.

Parameters:value (Boolean) – Run on Sunday?
setThursday(value)

Specify whether to run on Thursday. :param value: Run on Thursday? :type value: Boolean

setTuesday(value)

Specify whether to run on Tuesday. :param value: Run on Tuesday? :type value: Boolean

setWednesday(value)

Specify whether to run on Wednesday. :param value: Run on Wednesday? :type value: Boolean

einstein.modules.schedules.profiles.exportWeeklyProfilesFromDB()

Export all stored weekly profiles from data base in fractional weekly hour format.

Returns:{“name” : name of weekly profile, “intervals” : [{“start” : start hour point in week, “stop” : stop hour point in week, “scale” : load [0,1]}]}
Return type:Dictionary
einstein.modules.schedules.profiles.findBeginnings(list)
einstein.modules.schedules.profiles.getAllProfilesFromDB()

Convenience function to get all known profiles at once.

einstein.modules.schedules.profiles.getProfileIndexByName(uname, profiles)

Retrieve index of profile in instance list by profile name.

Parameters:
  • name (String) – Name of the profile to look for
  • profiles (List of profile instances) – Profiles to choose from
Returns:

Index of profile with name in list

Return type:

Integer

einstein.modules.schedules.profiles.getProfileNamesFromDB()

Retrieve known profile names from data base.

Returns:All profile names stored in data base.
Return type:List of strings
einstein.modules.schedules.profiles.processExists(processId)
einstein.modules.schedules.profiles.weekdayShort = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')

Weekday short names in order.

einstein.modules.schedules – Detailed schedules of periodic operation

synopsis:Periodic yearly load profiles of process operation
author:Hans Schweiger <hans.schweiger@energyxperts.net>
author:David Baehrens <david.baehrens@energyxperts.net>
class einstein.modules.schedules.schedules.Schedule(name)

class that defines EINSTEIN schedules

self.holidays: list of tuples of holiday (start,stop) periods (both inclusive, period across the end of the year is supported.

fav: hourly scale factor

Specific parameters for simplified schedules built as follows:

f(t) = fmonth * fweek *fholiday

self.weekly: list of tuples (start,stop) that describe the weekly profile (on/off) self.monthly: list of 12 monthly scale factors self.daily: intermediate list for daily profile, used for building self.weekly

NHolidays
build_fav()
calc_fav(time)
calc_weekly()

calculates a weekly fav-vector that then is extended to a year

input: self.weekly output: fweek

f(time)
isHoliday(day)
normalize()
setDefault()

Based on the basic schedule parameters (basic Q) assign a detailed default schedule

setPars(scheduleType, NDays, HPerDay, NBatch, HBatch, holidays, periodSchedule=None, subType='operation')
setParsDetailed()

functions for setpars specific for detailed schedules

zero()

sets the schedule to zero without calculations

class einstein.modules.schedules.schedules.Schedules

Bases: object

calculateEquipmentSchedules()

Generate the Schedules of the equipments.

calculateProcessSchedules()

Calculate the Schedules of the processes.

calculateWHEESchedules()

Generate the Schedules of the electrical equipment w. waste heat

create()
einstein.modules.schedules.schedules.TOLERANCE_GAP = 0.5

Minimum time between consecutive cycles after random tolerance shift (hours)

einstein.modules.streams – In- and out-flowing streams

synopsis:Multiple streams of process input and output
author:David Baehrens <david.baehrens@energyxperts.net>
exception einstein.modules.streams.FluidNotFoundError

Bases: exceptions.Exception

No fluid with given id found in DB.

exception einstein.modules.streams.InconsistentDataBaseError

Bases: exceptions.Exception

BUG: Data base structure is inconsistent.

class einstein.modules.streams.InflowingStream(Name, Medium=None, dbfluid_id=None, PTInFlow=None, PTInFlowRec=None, VInFlowCycle=None, mInFlowNom=None, HeatRecExist=None, HInFlow=None, XInFlow=None, UPHc=None, QdotProc_c=None, ExternalSupply=True)

Bases: object

classdocs

deleteFromDB(processId)

Delete all streams with our name associated with given process

loadFromDB(processId)

Load stream with our name associated with given processId

saveToDB(processId, ANo=None, PId=None)

Save the stream attached to the given processId.

class einstein.modules.streams.OutflowingStream(Name, Medium=None, PTOutFlow=None, PTOutFlowRec=None, PTFinal=None, VOutFlowCycle=None, mOutFlowNom=None, HeatRecExist=None, HeatRecOK=None, HOutFlow=None, XOutFlow=None, UPHw=None, QdotProc_w=None, PTFinalRequired=None, UPHwReq=None, ExternalSupply=True)

Bases: object

classdocs

deleteFromDB(processId)

Delete all streams with our name associated with given process

loadFromDB(processId)

Load stream with our name associated with given processId

saveToDB(processId, ANo=None, PId=None)

Save the stream attached to the given processId.

exception einstein.modules.streams.ProcessStreamsNotFoundError

Bases: exceptions.Exception

No streams for process with given id found in DB.

exception einstein.modules.streams.StreamNotFoundError

Bases: exceptions.Exception

No stream with given name for process found in DB.

einstein.modules.streams.findStream(name=None, processId=None, streamType='in')

Currently streams are referred to by a unique name and the processId

einstein.modules.streams.getInflowingStreamNamesFromDB(processId)

Retrieve all known in-flowing stream names for given processId from data base.

Parameters:processId (Integer) – Id of process with in-flowing streams to look for.
Returns:All in-flowing stream names stored in data base for processId.
Return type:List of strings
einstein.modules.streams.getOutflowingStreamNamesFromDB(processId)

Retrieve all known out-flowing stream names for given processId from data base.

Parameters:processId (Integer) – Id of process with out-flowing streams to look for.
Returns:All out-flowing stream names stored in data base for processId.
Return type:List of strings
einstein.modules.streams.getStreams(processId)

Retrieve all streams associated with the given processId form the data base.

Parameters:processId (Integer) – Id of the process whose streams are to retrieved.
Returns:A 2-Tuple of lists of InflowingStream and OutflowingStream objects, (inflowing, outflowing).
Return type:a pair of lists, the first of InflowingStreams, the second of OutflowinStreams

einstein.modules.upgrade – Version upgrades

synopsis:Management of EINSTEIN version upgrades
author:David Baehrens <david.baehrens@energyxperts.net>
einstein.modules.upgrade.addDPSTminValues(projectIds=None)

Add a variable for the before fixed parameters delta process/supply temperature.

If no project IDs are given all projects are updated.

Parameters:projectIds – list of ProjectIDs
einstein.modules.upgrade.addExternalSupply(projectIds=None)

Add a variable for the before fixed parameters delta process/supply temperature.

If no project IDs are given all projects are updated.

Parameters:projectIds – list of ProjectIDs
einstein.modules.upgrade.addIndoorTemperatures(projectIds=None)

Add the target temperatures for building heating and cooling as derived from the temperatures of the supply.

If no project IDs are given all projects are updated.

Parameters:projectIds – list of ProjectIDs
einstein.modules.upgrade.assumeSoundEconomicData(projectIds=None)

Assume that the econmic data of old projects is fine as is. Otherwise all variable costs in old projects would be removed as the equipment would seem to have changed since the last TCA calculations.

If no project IDs are given all projects are updated.

Parameters:projectIds – list of ProjectIDs
einstein.modules.upgrade.changeSTCollectortype(projectIds=None)

Replace the type “Concentrating collector” with “Parabolic trough collector” in the dbsolarthermal table.

Parameters:projectIds – is ignored as it does not touch projects
einstein.modules.upgrade.connectTCADataToAlternatives(projectIds=None)

All TCA data sets now keep track of their project id and alternative number. Set these values for all old TCA data sets.

If no project IDs are given all projects are updated.

Parameters:projectIds – list of ProjectIDs
einstein.modules.upgrade.createProcessesForBuildings(projectIds=None)

Create processes that represent the heating, cooling and domestic hot water demand of a building.

Parameters:projectIds – list of ProjectIDs
einstein.modules.upgrade.getAllBuildings(projectIds)
einstein.modules.upgrade.getAllEquipment(projectIds)
einstein.modules.upgrade.getAllProcesses(projectIds)
einstein.modules.upgrade.lastUpgrade(version)
einstein.modules.upgrade.moveEconomicDataToCGeneralData(projectIds=None)

Move some economic parameters from the questionnaire to the cgeneraldata table, as they may be changed by the consistency check and questionnaire contains only data that is user input.

If no project IDs are given all projects are updated.

Parameters:projectIds – list of ProjectIDs
einstein.modules.upgrade.portProcessIOtoStreams(projectIds=None)

Map the inflow and outflow properties of the processes of a project to corresponding streams.

If the process has in VInFlowDay, mInFlow, vInFlowCycle an explicit 0 then no inflow stream is created. If the process has in VoutFlow, mOutFlow, vOutFlowNom an explicit 0 then no outflow stream is created. In the other cases the values of the new streams are taken from the process.

Parameters:projectIds (List) – a list of projectIds of projects to be converted.
einstein.modules.upgrade.resetHeatSourceLT(projectIds=None)

The type of the HeatSourceLT column has changed, all old values were ignored anyway, so reset them for imported projects.

An update of the complete database is not needed as this is part of the database schema changes. If projectIds is None nothing is done.

Parameters:projectIds – list of ProjectIDs
einstein.modules.upgrade.shiftTemperatureReCooling(projectIds=None)

Shift the parameter TemperatureReCooling for air and water cooled compression chillers, as the simulation code has changed to a different reference point.

If no project IDs are given all projects are updated.

Parameters:projectIds – list of ProjectIDs
einstein.modules.upgrade.updateChillerData(projectIds=None)

Adapt chiller data for versions 2.1 and before in order to reflect the changes in the chiller module:

HCGTEfficiency -> copy into HCGTEffReal, if applies with partload correction.

Parameters:projectIds – list of ProjectIDs
einstein.modules.upgrade.updateSolarThermalDB(projectIds=None)

Replace default data with more precise default data.

If a projectId is given, nothing is done. This function is only sensible for updates of the whole database.

einstein.modules.upgrade.upgradeDetailedSchedules(projectIds=None)

Parameter upgrades for compatibility with detailed schedules

einstein.modules.upgrade.upgradeEINSTEIN(targetVersion='2.4.02', sourceVersion=None, projectIds=None)

Perform all defined upgrades to reach the specified version of EINSTEIN

einstein.modules.upgrade.upgradeProjectData(projectIds=None)

Updates the key project data creation date -> remains None last modification date -> set to current date

Parameters:projectIds – list of ProjectIDs
einstein.modules.upgrade.upgradeTimeSchedules(projectIds=None)

Adapt chiller data for versions 2.1 and before in order to reflect the changes in the chiller module:

HCGTEfficiency -> copy into HCGTEffReal, if applies with partload correction.

Parameters:projectIds – list of ProjectIDs
einstein.modules.upgrade.upgradeWaterCooledChillerData(projectIds=None)

Updates the key project data creation date -> remains None last modification date -> set to current date

Parameters:projectIds – list of ProjectIDs