Esempio n. 1
0
    def total(self, state, usage):
        def totals():
            for equivalence in self.equivalences.select_related('type'):
                type, eq = equivalence.emission, equivalence.equivalence
                yield type.total(state, usage) * eq

        return sum(totals(), Quantity(0, self.unit))
Esempio n. 2
0
class Impact(models.Model):
	row = models.ForeignKey(Row, related_name='impacts')
	impact = models.ForeignKey('carbon.Impact')
	amount = models.FloatField()
	total = property(lambda self: Quantity(self.amount, self.impact.unit))

	class Meta:
		unique_together = 'row', 'impact'

	def __unicode__(self):
		return '%s for %s' % (self.impact, self.row)
Esempio n. 3
0
class Emission(models.Model):
	row = models.ForeignKey(Row, related_name='emissions')
	emission = models.ForeignKey('carbon.EmissionType')
	amount = models.FloatField()
	total = property(lambda self: Quantity(self.amount, self.emission.unit))

	class Meta:
		unique_together = 'row', 'emission'

	def __unicode__(self):
		return '%s for %s' % (self.emission, self.row)
Esempio n. 4
0
class Impact(Type):
    normalization = models.FloatField()
    weight = models.DecimalField(max_digits=5, decimal_places=5)
    unit = models.CharField(max_length=50, default='g')
    n = property(lambda self: Quantity(self.normalization, self.unit))

    def total(self, state, usage):
        def totals():
            for equivalence in self.equivalences.select_related('type'):
                type, eq = equivalence.emission, equivalence.equivalence
                yield type.total(state, usage) * eq

        return sum(totals(), Quantity(0, self.unit))

    def normalize(self, value):
        return (value / self.n).simplified.item()

    def __unicode__(self):
        return '%s (%s)' % (self.name, self.unit)
Esempio n. 5
0
    def __init__(self,
                 building,
                 standard,
                 location,
                 year,
                 carbon,
                 deflator,
                 marr=None):
        self.master = self
        self.building = building
        self.location = location
        self.standard = standard
        self.year = year if isinstance(year, Quantity) else Quantity(
            year, 'years')
        self.data = EnergyPlusData.objects.get(building=building,
                                               location=location,
                                               standard=standard)
        self.deflator = float(deflator)
        self.marr = float(marr or deflator)

        try:
            self.set = ResultSet.objects.get(deflator=Decimal(str(deflator)),
                                             marr=Decimal(marr
                                                          or str(deflator)))
        except ResultSet.DoesNotExist:
            self.set = None

        self.components = ComponentCostList(self)
        self.assemblies = AssemblyCostList(self)
        self.energy = EnergyCost(self)
        self.mrr = MRR(self)
        self.base_residual = BaseResidual(self)
        self.residual = ResidualValue(self)
        self.energy_efficiency = EnergyEfficiencyCost(self)
        self.first = FirstCost(self)
        self.future = FutureCost(self)
        self.investment = InvestmentCost(self)
        self.lifecycle = LifeCycleCost(self)

        self.emissions = Emissions(self, carbon)
Esempio n. 6
0
from relator.assemblies.models import Fuel
from relator.structures.models import Building
from relator.standards.models import Standard
from relator.locations.models import State, Location
from relator.data.models import EnergyPlusData
from relator.energy.models import FuelData
from relator.units import Quantity
import os, csv

root = os.path.join('energy', 'data')
electric = Fuel.objects.get(name='Electric')
gas = Fuel.objects.get(name='Gas')
convert = lambda cell: Quantity(float(cell.strip()), 'joules')
okgo = False


def locate_eplus(filename):
    building, location, standard = filename[:-9].split('-')
    print building, location, standard
    building = Building.objects.get(type=building)
    standard = Standard.objects.get(name=standard)
    state, location = location[4:6], location[7:]
    state = State.objects.get(code=state)
    name = location.replace('_', ' ').title()
    if name == 'Worchester': name = 'Worcester'
    try:
        location = Location.objects.get(state=state, name__iexact=name)
    except Location.DoesNotExist:
        location = Location.objects.get(state=state,
                                        name__istartswith=name.split(' ')[0])
    return EnergyPlusData.objects.get(location=location,
Esempio n. 7
0
 def data():
     for building in buildings:
         for location in locations:
             for year in (Quantity(length, 'years') for length in years):
                 yield Comparison(standards, building, location, year,
                                  **variables)
Esempio n. 8
0
class Emission(EmissionUnit):
    type = models.ForeignKey(data.EmissionType, related_name='computed')
    amount = property(lambda self: Quantity(self.value, self.type.unit))
    create = classmethod(lambda cls, data, type: cls.base(data, 'type', type))
Esempio n. 9
0
class Impact(EmissionUnit):
    impact = models.ForeignKey(data.Impact, related_name='computed')
    amount = property(lambda self: Quantity(self.value, self.impact.unit))
    create = classmethod(
        lambda cls, data, impact: cls.base(data, 'impact', impact))
Esempio n. 10
0
 def total(self, usage):
     none = Quantity(0, 'BTU')
     return self.flow * (usage.get(self.fuel, none).into('BTU'))
Esempio n. 11
0
 def flow(self):
     return Quantity(self.value, '(%s) / BTU' % self.type.unit).view()