[GRASS-SVN] r70955 - in grass-addons/grass7/raster/r.green: . r.green.gshp r.green.gshp/libgshp r.green.gshp/libgshp/testsuite r.green.gshp/libgshp/testsuite/data r.green.gshp/r.green.gshp.theoretical

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 26 05:53:25 PDT 2017


Author: zarch
Date: 2017-04-26 05:53:25 -0700 (Wed, 26 Apr 2017)
New Revision: 70955

Added:
   grass-addons/grass7/raster/r.green/r.green.gshp/
   grass-addons/grass7/raster/r.green/r.green.gshp/Makefile
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/Makefile
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/__init__.py
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/gpot.py
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/__init__.py
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/energy_xs.ascii
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/gmax_xs.ascii
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/ground_capacity_xs.ascii
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/length_xs.ascii
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/norm_time_heatseason_xs.ascii
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/norm_time_lifetime_xs.ascii
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/power_xs.ascii
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/test_gpot.py
   grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.html
   grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/
   grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/Makefile
   grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.html
   grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.py
Log:
r.green: Add ground source heat pump theoretical potential

Added: grass-addons/grass7/raster/r.green/r.green.gshp/Makefile
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/Makefile	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/Makefile	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,12 @@
+MODULE_TOPDIR = ../../..
+
+PGM=r.green.gshp
+
+SUBDIRS = libgshp \
+	r.green.gshp.theoretical
+
+include $(MODULE_TOPDIR)/include/Make/Dir.make
+
+default: parsubdirs htmldir
+
+install: installsubdirs


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/Makefile
___________________________________________________________________
Added: svn:mime-type
   + text/x-makefile
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/Makefile
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/Makefile	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/Makefile	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,25 @@
+MODULE_TOPDIR = ../../../..
+
+include $(MODULE_TOPDIR)/include/Make/Other.make
+include $(MODULE_TOPDIR)/include/Make/Python.make
+
+MODULES = gpot __init__
+
+PGM = r.green
+LIBDIR = libgshp
+ETCDIR = $(ETC)/$(PGM)/$(LIBDIR)
+
+PYFILES := $(patsubst %,$(ETCDIR)/%.py,$(MODULES))
+PYCFILES := $(patsubst %,$(ETCDIR)/%.pyc,$(MODULES))
+
+default: $(PYFILES) $(PYCFILES)
+
+$(ETCDIR):
+	$(MKDIR) $@
+
+$(ETCDIR)/%: % | $(ETCDIR)
+	$(INSTALL_DATA) $< $@
+
+install:
+	$(MKDIR) $(INST_DIR)/etc/$(PGM)
+	cp -r $(ETCDIR) $(INST_DIR)/etc/$(PGM)/$(LIBDIR)


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/Makefile
___________________________________________________________________
Added: svn:mime-type
   + text/x-makefile
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/__init__.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/__init__.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/__init__.py	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1 @@
+ 


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/__init__.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/gpot.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/gpot.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/gpot.py	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,213 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+ at author:
+    - code: Pietro Zambelli
+    - methodology: Alessandro Casasso & Rajandrea Sethi
+
+
+Alessandro Casasso, Rajandrea Sethi, 2016,
+"G.POT: A quantitative method for the assessment and mapping of the
+shallow geothermal potential"
+Energy 106, p 765 -- 773
+http://dx.doi.org/10.1016/j.energy.2016.03.091
+
+
+Variables
+---------
+
+QBHE is the yearly average thermal load that can sustainably be exchanged by a
+Borehole Heat Exchanger with a certain length, for a given ground condition.
+
+The geothermal potential can be calculated both for cooling and
+or heating mode and it depends on:
+
+ground thermal properties:
+    - thermal conductivity (l),
+    - thermal capacity (rc) and
+    - undisturbed ground temperature (T0);
+geometrical and thermal properties of BHE:
+    - borehole depth (L),
+    - borehole radius (rb) and
+    - thermal resistance (Rb);
+operative criteria:
+    - minimum temperature of the carrier fluid during heating mode (Tlim)
+    - maximum temperature of the carrier fluid during cooling mode
+    - length of heating season (tc);
+    - lenght of cooling season (tc);
+simulation parameters:
+    - simulation time (ts): time over which the sustainability of the
+      geo-exchange is evaluated.
+
+"""
+from numpy import pi, log, sqrt
+
+# import grass libraries
+from grass.script import raster as grast
+
+
+def get_borehole_resistence(borehole_radius, pipe_radius, number_pipes,
+                            grout_conductivity):
+    """Borehole thermal resistence, following the Shonder and Beck (2000)
+    method.
+
+    Example
+    -------
+    >>> get_borehole_resistence(borehole_radius=0.075, pipe_radius=0.016,
+    ...                         number_pipes=4, grout_conductivity=2.)
+    ...                                                   # doctest: +ELLIPSIS
+    0.067780287314088528
+    """
+    return (1. / (2 * pi * grout_conductivity) *
+            log(borehole_radius /
+                (sqrt(number_pipes) * pipe_radius)))
+
+
+def norm_time(time, borehole_radius, ground_conductivity, ground_capacity):
+    """Normalized time in s
+
+    Example
+    -------
+    >>> norm_time(180 * 24 * 60 * 60, borehole_radius=0.075,
+    ...           ground_conductivity=2., ground_capacity=2.5)
+    ...                                                   # doctest: +ELLIPSIS
+    0.00011302806712962963
+    >>> norm_time(50 * 365 * 24 * 60 * 60, borehole_radius=0.075,
+    ...           ground_conductivity=2., ground_capacity=2.5)
+    ...                                                   # doctest: +ELLIPSIS
+    1.1147973744292237e-06
+    """
+    return (borehole_radius**2. /
+            (4 * ground_conductivity / ground_capacity *
+             0.000001 * time))
+
+
+def r_norm_time(out, time, borehole_radius,
+                ground_conductivity, ground_capacity, execute=True, **kwargs):
+    """Normalized time in s
+
+    Example
+    -------
+    >>> r_norm_time('norm_time', 180 * 24 * 60 * 60, borehole_radius=0.075,
+    ...           ground_conductivity=2., ground_capacity=2.5, execute=False)
+    'norm_time = (0.075^2. / (4 * 2.0 / 2.5 * 0.000001 * 15552000))'
+    >>> r_norm_time('norm_time', 50 * 365 * 24 * 60 * 60, borehole_radius=0.075,
+    ...             ground_conductivity='ground_conductivity',
+    ...             ground_capacity='ground_capacity', execute=False)
+    'norm_time = (0.075^2. / (4 * ground_conductivity / ground_capacity * 0.000001 * 1576800000))'
+    """
+    res = ("{out} = ({borehole_radius}^2. / (4 * {ground_conductivity} / "
+           "{ground_capacity} * 0.000001 * {time}))")
+    rcmd = res.format(out=out, borehole_radius=borehole_radius,
+                      ground_conductivity=ground_conductivity,
+                      ground_capacity=ground_capacity, time=time)
+    if execute:
+        grast.mapcalc(rcmd, **kwargs)
+    return rcmd
+
+
+def norm_thermal_alteration(tc, uc, us):
+    """Normalized thermal alteration
+
+    Example
+    -------
+
+    >>> norm_thermal_alteration(tc=180./365., uc=1.130280671296e-4,
+    ...                         us=1.114797374429e-6)     # doctest: +ELLIPSIS
+    8.69904482466...
+
+    """
+    # -0.619*180./365. * log(1.114797374429e-6) + (0.532* 180./365. - 0.962) *
+    # log(1.130280671296e-4)-0.455 * 180./ 365.- 1.619
+    return (-0.619 * tc * log(us) +
+            (0.532 * tc - 0.962) * log(uc) - 0.455 * tc - 1.619)
+
+
+def r_norm_thermal_alteration(out, tc, uc, us, execute=True, **kwargs):
+    """Normalized thermal alteration
+
+    Example
+    -------
+
+    >>> r_norm_thermal_alteration(out='gmax', tc=180./365.,
+    ...                           uc=1.114797374429E-06,
+    ...                           us=1.130280671296E-04, execute=False)
+    ...                                                   # doctest: +ELLIPSIS
+    'gmax = (-0.619 * 0.493150684... * log(0.000113028...) + (0.532 * 0.4931506849... - 0.962) * log(1.11479737...e-06) - 0.455 * 0.493150684... - 1.619)'
+    >>> r_norm_thermal_alteration(out='gmax', tc=180./365., uc='uc',
+    ...                           us='us', execute=False) # doctest: +ELLIPSIS
+    'gmax = (-0.619 * 0.493150684... * log(us) + (0.532 * 0.4931506849... - 0.962) * log(uc) - 0.455 * 0.493150684... - 1.619)'
+    """
+    res = ("{out} = (-0.619 * {tc} * log({us}) + "
+           "(0.532 * {tc} - 0.962) * log({uc}) - 0.455 * {tc} - 1.619)")
+    rcmd = res.format(out=out, tc=tc, us=us, uc=uc)
+    if execute:
+        grast.mapcalc(rcmd, **kwargs)
+    return rcmd
+
+
+def power(tc, ground_conductivity, ground_temperature, fluid_limit_temperature,
+          borehole_length, borehole_resistence, gmax):
+    """Return the potential power using the g.pot method in W
+
+    Example
+    -------
+    >>> power(tc=180./365., ground_conductivity=2., ground_temperature=10.,
+    ...       fluid_limit_temperature=-2.,
+    ...       borehole_length=100., borehole_resistence=0.1,
+    ...       gmax=8.6990448246621082)                     # doctest: +ELLIPSIS
+    844.472333...
+    """
+    return ((8. * (ground_temperature - fluid_limit_temperature) *
+             ground_conductivity * borehole_length * tc) /
+            (gmax + 4 * pi * ground_conductivity * borehole_resistence))
+
+
+def r_power(out, tc, ground_conductivity, ground_temperature,
+            fluid_limit_temperature, borehole_length, borehole_resistence,
+            gmax, execute=True, **kwargs):
+    """Return the potential power using the g.pot method in W
+
+    Example
+    -------
+    >>> r_power(out='power', tc=180./365.,
+    ...         ground_conductivity='ground_conductivity',
+    ...         ground_temperature='ground_temperature',
+    ...         fluid_limit_temperature=-2.,
+    ...         borehole_length=100., borehole_resistence=0.1,
+    ...         gmax='gmax', execute=False)                # doctest: +ELLIPSIS
+    'power = ((8. * (ground_temperature - -2.0) * ground_conductivity * 100.0 * 0.493150684...) / (gmax + 4 * 3.141592653... * ground_conductivity * 0.1))'
+    """
+    res = ("{out} = ((8. * ({ground_temperature} - {fluid_limit_temperature}) * "
+           "{ground_conductivity} * {borehole_length} * {tc}) / "
+           "({gmax} + 4 * {pi} * {ground_conductivity} * {borehole_resistence}))")
+    rcmd = res.format(out=out, tc=tc, ground_conductivity=ground_conductivity,
+                      ground_temperature=ground_temperature,
+                      fluid_limit_temperature=fluid_limit_temperature,
+                      pi=pi,
+                      borehole_length=borehole_length,
+                      borehole_resistence=borehole_resistence,
+                      gmax=gmax)
+    if execute:
+        grast.mapcalc(rcmd, **kwargs)
+    return rcmd
+
+
+def r_energy(out, power, execute=True, **kwargs):
+    """Return the potential energy using the g.pot method in MWh/year
+
+    Example
+    -------
+    >>> r_energy('energy', 'power', execute=False)
+    'energy = 0.00876 * power'
+    """
+    res = "{out} = 0.00876 * {power}"
+    rcmd = res.format(out=out, power=power)
+    if execute:
+        grast.mapcalc(rcmd, **kwargs)
+    return rcmd
+
+
+if __name__ == '__main__':
+    import doctest
+    doctest.testmod()


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/gpot.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/__init__.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/energy_xs.ascii
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/energy_xs.ascii	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/energy_xs.ascii	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,14 @@
+north: 40
+south: 10
+east: 100
+west: 50
+rows: 8
+cols: 6
+7.8201953800014 8.5483188164961 8.9481702027677 10.4223290667456 11.7173041500822 12.8534554881166
+7.8201953800014 8.5483188164961 8.9481702027677 10.4223290667456 11.7173041500822 12.8534554881166
+7.8201953800014 8.5483188164961 8.9481702027677 10.4223290667456 11.7173041500822 12.8534554881166
+7.8201953800014 8.5483188164961 8.9481702027677 10.4223290667456 11.7173041500822 12.8534554881166
+7.8201953800014 8.5483188164961 8.9481702027677 10.4223290667456 11.7173041500822 12.8534554881166
+7.8201953800014 8.5483188164961 8.9481702027677 10.4223290667456 11.7173041500822 12.8534554881166
+7.8201953800014 8.5483188164961 8.9481702027677 10.4223290667456 11.7173041500822 12.8534554881166
+7.8201953800014 8.5483188164961 8.9481702027677 10.4223290667456 11.7173041500822 12.8534554881166


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/energy_xs.ascii
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/gmax_xs.ascii
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/gmax_xs.ascii	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/gmax_xs.ascii	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,14 @@
+north: 40
+south: 10
+east: 100
+west: 50
+rows: 8
+cols: 6
+8.78102488885101 8.91521113405854 8.98562231568097 9.22931537948381 9.42773116917176 9.59335597761912
+8.78102488885101 8.91521113405854 8.98562231568097 9.22931537948381 9.42773116917176 9.59335597761912
+8.78102488885101 8.91521113405854 8.98562231568097 9.22931537948381 9.42773116917176 9.59335597761912
+8.78102488885101 8.91521113405854 8.98562231568097 9.22931537948381 9.42773116917176 9.59335597761912
+8.78102488885101 8.91521113405854 8.98562231568097 9.22931537948381 9.42773116917176 9.59335597761912
+8.78102488885101 8.91521113405854 8.98562231568097 9.22931537948381 9.42773116917176 9.59335597761912
+8.78102488885101 8.91521113405854 8.98562231568097 9.22931537948381 9.42773116917176 9.59335597761912
+8.78102488885101 8.91521113405854 8.98562231568097 9.22931537948381 9.42773116917176 9.59335597761912


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/gmax_xs.ascii
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/ground_capacity_xs.ascii
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/ground_capacity_xs.ascii	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/ground_capacity_xs.ascii	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,16 @@
+north:   40
+south:   10
+east:    100
+west:    50
+rows:    8
+cols:    6
+
+2.17 2.48 2.66 3.39 4.13 4.87
+2.17 2.48 2.66 3.39 4.13 4.87
+2.17 2.48 2.66 3.39 4.13 4.87
+2.17 2.48 2.66 3.39 4.13 4.87
+2.17 2.48 2.66 3.39 4.13 4.87
+2.17 2.48 2.66 3.39 4.13 4.87
+2.17 2.48 2.66 3.39 4.13 4.87
+2.17 2.48 2.66 3.39 4.13 4.87
+


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/ground_capacity_xs.ascii
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/length_xs.ascii
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/length_xs.ascii	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/length_xs.ascii	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,14 @@
+north: 40
+south: 10
+east: 100
+west: 50
+rows: 8
+cols: 6
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 0.0000464180973838 
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 0.0000464180973838 
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 0.0000464180973838 
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 0.0000464180973838 
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 0.0000464180973838 
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 0.0000464180973838 
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 0.0000464180973838 
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 0.0000464180973838 


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/length_xs.ascii
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/norm_time_heatseason_xs.ascii
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/norm_time_heatseason_xs.ascii	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/norm_time_heatseason_xs.ascii	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,15 @@
+north: 40
+south: 10
+east: 100
+west: 50
+rows: 8
+cols: 6
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 4.6418097383832E-05
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 4.6418097383832E-05
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 4.6418097383832E-05
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 4.6418097383832E-05
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 4.6418097383832E-05
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 4.6418097383832E-05
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 4.6418097383832E-05
+0.00010417333376 0.00009115166704 0.00008498350912 0.0000666832254452 0.0000547351414671 4.6418097383832E-05
+


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/norm_time_heatseason_xs.ascii
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/norm_time_lifetime_xs.ascii
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/norm_time_lifetime_xs.ascii	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/norm_time_lifetime_xs.ascii	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,15 @@
+north: 40
+south: 10
+east: 100
+west: 50
+rows: 8
+cols: 6
+1.0274630179071E-06 8.9903014066873E-07 8.3819351460844E-07 6.5769756603494E-07 5.3985345008679E-07 4.5782233036108E-07
+1.0274630179071E-06 8.9903014066873E-07 8.3819351460844E-07 6.5769756603494E-07 5.3985345008679E-07 4.5782233036108E-07
+1.0274630179071E-06 8.9903014066873E-07 8.3819351460844E-07 6.5769756603494E-07 5.3985345008679E-07 4.5782233036108E-07
+1.0274630179071E-06 8.9903014066873E-07 8.3819351460844E-07 6.5769756603494E-07 5.3985345008679E-07 4.5782233036108E-07
+1.0274630179071E-06 8.9903014066873E-07 8.3819351460844E-07 6.5769756603494E-07 5.3985345008679E-07 4.5782233036108E-07
+1.0274630179071E-06 8.9903014066873E-07 8.3819351460844E-07 6.5769756603494E-07 5.3985345008679E-07 4.5782233036108E-07
+1.0274630179071E-06 8.9903014066873E-07 8.3819351460844E-07 6.5769756603494E-07 5.3985345008679E-07 4.5782233036108E-07
+1.0274630179071E-06 8.9903014066873E-07 8.3819351460844E-07 6.5769756603494E-07 5.3985345008679E-07 4.5782233036108E-07
+


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/norm_time_lifetime_xs.ascii
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/power_xs.ascii
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/power_xs.ascii	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/power_xs.ascii	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,14 @@
+north: 40
+south: 10
+east: 100
+west: 50
+rows: 8
+cols: 6
+892.71636758007 975.83548133517 1021.48061675430 1189.76359209425 1337.59179795458 1467.28943928271
+892.71636758007 975.83548133517 1021.48061675430 1189.76359209425 1337.59179795458 1467.28943928271
+892.71636758007 975.83548133517 1021.48061675430 1189.76359209425 1337.59179795458 1467.28943928271
+892.71636758007 975.83548133517 1021.48061675430 1189.76359209425 1337.59179795458 1467.28943928271
+892.71636758007 975.83548133517 1021.48061675430 1189.76359209425 1337.59179795458 1467.28943928271
+892.71636758007 975.83548133517 1021.48061675430 1189.76359209425 1337.59179795458 1467.28943928271
+892.71636758007 975.83548133517 1021.48061675430 1189.76359209425 1337.59179795458 1467.28943928271
+892.71636758007 975.83548133517 1021.48061675430 1189.76359209425 1337.59179795458 1467.28943928271


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/data/power_xs.ascii
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/test_gpot.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/test_gpot.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/test_gpot.py	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,208 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+Test GPOT implementation
+"""
+from __future__ import (absolute_import, division, generators, nested_scopes,
+                        print_function, unicode_literals, with_statement)
+import os
+
+from numpy.testing import assert_almost_equal
+
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+from grass.gunittest.gmodules import call_module
+
+
+import gpot as gpot
+
+
+# ==================================================================
+# Define value and results to be tested as scalar and as raster
+GRND_CONDUCTIVITY = [2.17, 2.48, 2.66, 3.39, 4.13, 4.87]
+Us = [1.0274630179071e-06, 8.9903014066873e-07, 8.3819351460844e-07,
+      6.5769756603494e-07, 5.3985345008679e-07, 6.4095126250551e-07, ]
+Uc = [1.0417333376003e-04, 9.1151667040024e-05, 8.4983509120022e-05,
+      6.6683225445209e-05, 5.4735141467133e-05, 6.4626301329975e-05, ]
+GMAX = [8.78102488885101, 8.91521113405854, 8.98562231568097,
+        9.22931537948381, 9.42773116917176, 9.26798647784601, ]
+ENRG = [7.8201953800014, 8.5483188164961, 8.9481702027677,
+        10.4223290667456, 11.7173041500822, 14.2980012600415, ]
+PWR = [892.71636758007, 975.83548133517, 1021.48061675430,
+       1189.76359209425, 1337.59179795458, 1632.19192466227, ]
+GRND_TEMP = 10.
+GRND_CAPACITY = 2.5
+FLUID_TEMP = -2.
+HEATING_SEASON = 180 * 24 * 60 * 60
+LIFETIME = 50 * 365 * 24 * 60 * 60
+
+BH_DEPTH = 100.
+BH_RADIUS = 0.075
+BH_THERM_RESISTANCE = 0.1
+
+PIPE_RADIUS = 0.016
+NUM_PIPES = 4
+GROUT_CONDUCTIVITY = 2.
+
+
+# ==================================================================
+# Start testing the library
+from grass.pygrass.raster import RasterRow
+
+
+def assert_raster_no_difference(reference, actual, precision):
+    with RasterRow(reference) as ref, RasterRow(actual) as act:
+        for i_row, (r_row, a_row) in enumerate(zip(ref, act)):
+            diff = abs(r_row - a_row) > precision
+            if diff.any():
+                cols = diff.nonzero()
+                msg = ("The two rows are different!\nrow:{i_row}, "
+                       "cols={cols}\nref: {ref}\nact:{act}")
+                raise AssertionError(msg.format(i_row=i_row, cols=cols,
+                                                ref=r_row[cols],
+                                                act=a_row[cols]))
+
+
+class TestBHEresistence(TestCase):
+    def test_resistence(self):
+        """Test function that return the thermal resistence of a BHE"""
+        res = gpot.get_borehole_resistence(borehole_radius=BH_RADIUS,
+                                           pipe_radius=PIPE_RADIUS,
+                                           number_pipes=NUM_PIPES,
+                                           grout_conductivity=GROUT_CONDUCTIVITY)
+        assert_almost_equal(0.067780287314088528, res)
+
+
+class TestGPot(TestCase):
+    def test_norm_time(self):
+        """Test time normalization function
+        """
+        for time, result in zip((HEATING_SEASON, LIFETIME),
+                                (0.00011302806712962963, 1.1147973744292237e-06)):
+            res = gpot.norm_time(time, borehole_radius=BH_RADIUS,
+                                 ground_conductivity=2.,
+                                 ground_capacity=GRND_CAPACITY)
+            assert_almost_equal(result, res)
+
+
+class TestRasterGPot(TestCase):
+    precision = 1e-7
+    base = 'gpottest_'
+    dirpath = os.path.join('testsuite', 'data')
+
+    # define names
+    grnd_conductivity = base + 'ground_conductivity'
+    norm_time_hs_comp = base + 'normtime_heatingseason_comp'
+    norm_time_hs_ref = base + 'normtime_heatingseason_ref'
+    norm_time_lt_comp = base + 'normtime_lifetime_comp'
+    norm_time_lt_ref = base + 'normtime_lifetime_ref'
+    gmax_comp = base + 'gmax_comp'
+    gmax_ref = base + 'gmax_ref'
+    power_comp = base + 'power_comp'
+    power_ref = base + 'power_ref'
+    energy_comp = base + 'energy_comp'
+    energy_ref = base + 'energy_ref'
+    length_comp = base + 'length_comp'
+    length_ref = base + 'length_ref'
+
+    # define paths
+    grnd_conductivity_file = os.path.join(dirpath, 'ground_capacity_xs.ascii')
+    norm_time_hs_ref_file = os.path.join(dirpath, 'norm_time_heatseason_xs.ascii')
+    norm_time_lt_ref_file = os.path.join(dirpath, 'norm_time_lifetime_xs.ascii')
+    gmax_ref_file = os.path.join(dirpath, 'gmax_xs.ascii')
+    power_ref_file = os.path.join(dirpath, 'power_xs.ascii')
+    energy_ref_file = os.path.join(dirpath, 'energy_xs.ascii')
+    length_ref_file = os.path.join(dirpath, 'length_xs.ascii')
+
+    @classmethod
+    def setUpClass(cls):
+        """Ensures expected computational region"""
+        # to not override mapset's region (which might be used by other tests)
+        cls.use_temp_region()
+        call_module('r.in.ascii', input=cls.grnd_conductivity_file,
+                    output=cls.grnd_conductivity, overwrite=True)
+        call_module('r.in.ascii', input=cls.norm_time_hs_ref_file,
+                    output=cls.norm_time_hs_ref, overwrite=True)
+        call_module('r.in.ascii', input=cls.norm_time_lt_ref_file,
+                    output=cls.norm_time_lt_ref, overwrite=True)
+        call_module('r.in.ascii', input=cls.gmax_ref_file,
+                    output=cls.gmax_ref, overwrite=True)
+        call_module('r.in.ascii', input=cls.power_ref_file,
+                    output=cls.power_ref, overwrite=True)
+        call_module('r.in.ascii', input=cls.energy_ref_file,
+                    output=cls.energy_ref, overwrite=True)
+        call_module('g.region', raster=cls.grnd_conductivity)
+
+    @classmethod
+    def tearDownClass(cls):
+        # TODO: clean
+        cls.del_temp_region()
+
+    def test_norm_time_hs(self):
+        """Test time normalization function applied to raster for heating season
+        """
+        # heating season
+        gpot.r_norm_time(self.norm_time_hs_comp, HEATING_SEASON,
+                         borehole_radius=BH_RADIUS,
+                         ground_conductivity=self.grnd_conductivity,
+                         ground_capacity=GRND_CAPACITY,
+                         execute=True, overwrite=True)
+        # check against reference data
+        assert_raster_no_difference(actual=self.norm_time_hs_comp,
+                                    reference=self.norm_time_hs_ref,
+                                    precision=self.precision)
+
+    def test_norm_time_lt(self):
+        """Test time normalization function applied to raster for lifetime
+        """
+        # lifetime
+        gpot.r_norm_time(self.norm_time_lt_comp, LIFETIME,
+                         borehole_radius=BH_RADIUS,
+                         ground_conductivity=self.grnd_conductivity,
+                         ground_capacity=GRND_CAPACITY,
+                         execute=True, overwrite=True)
+        # check against reference data
+        assert_raster_no_difference(actual=self.norm_time_lt_comp,
+                                    reference=self.norm_time_lt_ref,
+                                    precision=self.precision)
+#        self.assertRastersNoDifference(actual=norm_time_hs_comp,
+#                                       reference=norm_time_hs_ref,
+#                                       precision=self.precision)
+
+    def test_norm_thermal_alteration(self):
+        """Test normarl thermal alteration"""
+        # out, tc, uc, us, execute=True, **kwargs)
+        gpot.r_norm_thermal_alteration(out=self.gmax_comp,
+                                       tc=HEATING_SEASON/(365. * 24 * 60 * 60),
+                                       uc=self.norm_time_hs_ref,
+                                       us=self.norm_time_lt_ref,
+                                       execute=True, overwrite=True)
+        assert_raster_no_difference(actual=self.gmax_comp,
+                                    reference=self.gmax_ref,
+                                    precision=self.precision)
+
+    def test_power(self):
+        """Test power function"""
+        gpot.r_power(out=self.power_comp,
+                     tc=180./365.,
+                     ground_conductivity=self.grnd_conductivity,
+                     ground_temperature=10.,
+                     fluid_limit_temperature=-2.,
+                     borehole_length=100., borehole_resistence=0.1,
+                     gmax=self.gmax_ref,
+                     execute=True, overwrite=True)
+        assert_raster_no_difference(actual=self.power_comp,
+                                    reference=self.power_ref,
+                                    precision=self.precision)
+
+    def test_energy(self):
+        """Test energy function"""
+        gpot.r_energy(out=self.energy_comp, power=self.power_ref,
+                      execute=True, overwrite=True)
+        assert_raster_no_difference(actual=self.energy_comp,
+                                    reference=self.energy_ref,
+                                    precision=self.precision)
+
+
+if __name__ == '__main__':
+    test()


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/testsuite/test_gpot.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.html
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.html	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.html	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,35 @@
+<h2>DESCRIPTION</h2>
+
+The module r.green.gshp computes the Ground Source Heat Pump potential. <br>
+It is composed of several programs considering different limits (e.g. theoretical, planning, technical, economic/finacial constraints).<br>
+
+The module r.green.gshp consists of the following different parts:<br><br>
+
+- <a href="r.green.gshp.theoretical.html">r.green.hydro.theoretical</a><br>
+  calculates for each basin the theoretical maximum hydropower energy potential<br>
+  input raster maps:    - discharge along river network      - elevation of the considered region<br>  
+  input vector map:       existing plant position<br>
+  output vector maps: - available river segments               - optimal plant position<br><br>
+
+- <a href="r.green.gshp.planning.html">r.green.hydro.recommended</a><br>
+  detects the potential plant position considering legal and ecological constraints and the user's recommendations<br>
+  input raster maps:    - discharge along river network      - elevation of the considered region     - minimum flow discharge<br>  
+  input vector maps:    - existing plant position                    -  areas excluded from calculation<br>
+  output vector maps: - available river segments               - optimal plant position<br><br>
+
+- <a href="r.green.gshp.technical.html">r.green.hydro.technical</a><br>
+  calculates the hydropower potential considering technical constrains (head losses, efficiency of turbine)<br>
+  input vector map:       intakes and restitutions of the potential plants<br>
+  output vector map:  - structure (derivation channel and penstock) on both sides of the river for each potential plant<br><br>
+
+- <a href="r.green.gshp.financial.html">r.green.hydro.financial</a><br>
+  computes the economic costs and values of the plants<br>
+  input raster maps:    - landuse      - slope<br>  
+  input vector maps:   - segments of the potential plants   - plant structure     - electric grid<br>
+  output vector map:    structure of the potential plants with a re-organized table with e.g. power, gross head, total cost<br><br>
+
+<h2>AUTHORS</h2>
+
+For authors and references, please refer to each module of r.green.
+
+<p><i>Last changed: $Date$</i>


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.html
___________________________________________________________________
Added: svn:mime-type
   + text/html
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/Makefile
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/Makefile	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/Makefile	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../../..
+
+PGM = r.green.gshp.theoretical
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/Makefile
___________________________________________________________________
Added: svn:mime-type
   + text/x-makefile
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.html
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.html	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.html	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,28 @@
+<h2>DESCRIPTION</h2>
+<em>r.green.gshp.theoretical</em> calculates .<br><br>
+
+<h2>NOTES</h2>
+
+The required inputs are the <br><br>
+
+
+<h2>EXAMPLES</h2>
+
+
+
+<h2>SEE ALSO</h2>
+<em>
+<a href="r.green.gshp.technical.html">r.green.hydro.technical</a><br>
+</em>
+
+<h2>AUTHORS</h2>
+Pietro Zambelli (Eurac Research, Bolzano, Italy)<br>
+
+<h2>REFERENCES</h2>
+Alessandro Casasso, Rajandrea Sethi, 2016,<br>
+"G.POT: A quantitative method for the assessment and mapping of the
+shallow geothermal potential"<br>
+Energy 106, p 765 -- <br>
+http://dx.doi.org/10.1016/j.energy.2016.03.091<br>
+
+<p><i>Last changed: $Date$</i>


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.html
___________________________________________________________________
Added: svn:mime-type
   + text/html
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.py	2017-04-26 12:53:25 UTC (rev 70955)
@@ -0,0 +1,324 @@
+#!/usr/bin/env python2
+# -*- coding: utf-8 -*-
+#
+############################################################################
+#
+# MODULE:      r.green.geothermal.potential
+# AUTHOR(S):   Pietro Zambelli
+# PURPOSE:     Calculate the Near Surface Geothermal Energy potential
+# COPYRIGHT:   (C) 2017 by the GRASS Development Team
+#
+#              This program is free software under the GNU General Public
+#              License (>=v2). Read the file COPYING that comes with GRASS
+#              for details.
+#
+#############################################################################
+#
+
+#%module
+#% description: Calculate the Ground Source Heat Pump potential
+#% keywords: raster
+#%end
+
+##
+## REQUIRED INPUTS
+##
+#%option G_OPT_R_INPUT
+#% key: ground_conductivity
+#% description: Raster with depth-averaged ground thermal conductivity λ [W m-1 K-1]
+#% required: yes
+#%end
+
+##
+## OPTIONAL INPUTS
+##
+#%option
+#% key: heating_season
+#% type: double
+#% key_desc: double
+#% description: Heating Season [0-365] days
+#% required: no
+#% options: 0-365
+#% answer: 180.
+#% guisection: Demand
+#%end
+
+#%option
+#% key: power_value
+#% type: double
+#% key_desc: double
+#% description: Power value in kW
+#% required: no
+#% answer: nan
+#% guisection: Demand
+#%end
+
+#%option G_OPT_R_INPUT
+#% key: ground_capacity_rast
+#% description: Raster with depth-averaged ground thermal capacity ρc  [MJ m-3 K-1]
+#% required: no
+#% guisection: Ground
+#%end
+
+#%option
+#% key: ground_capacity_value
+#% type: double
+#% key_desc: double
+#% description: Value with depth-averaged ground thermal capacity ρc  [MJ m-3 K-1]
+#% required: no
+#% answer: 2.5
+#% guisection: Ground
+#%end
+
+
+#%option G_OPT_R_INPUT
+#% key: ground_temp_rast
+#% description: Raster with the initial ground temperature T0 [°C]
+#% required: no
+#% guisection: Ground
+#%end
+
+#%option
+#% key: ground_temp_value
+#% type: double
+#% key_desc: double
+#% description: Value with the initial ground temperature T0 [°C]
+#% required: no
+#% answer: 10.
+#% guisection: Ground
+#%end
+
+#%option
+#% key: borehole_radius
+#% type: double
+#% key_desc: double
+#% description: Borehole radius [m]
+#% required: no
+#% answer: 0.075
+#% guisection: Borehole
+#%end
+
+#%option
+#% key: borehole_resistence
+#% type: double
+#% key_desc: double
+#% description: Borehole thermal resistence [m K W-1]
+#% required: no
+#% answer: nan
+#% guisection: Borehole
+#%end
+
+#%option
+#% key: borehole_length
+#% type: double
+#% key_desc: double
+#% description: Borehole length [m]
+#% required: no
+#% answer: 100
+#% guisection: Borehole
+#%end
+
+#%option
+#% key: pipe_radius
+#% type: double
+#% key_desc: double
+#% description: Pipe radius [m]
+#% required: no
+#% answer: 0.016
+#% guisection: BHE
+#%end
+
+#%option
+#% key: number_pipes
+#% type: integer
+#% key_desc: integer
+#% description: Number of pipes in the borehole
+#% required: no
+#% answer: 4
+#% guisection: BHE
+#%end
+
+#%option
+#% key: grout_conductivity
+#% type: double
+#% key_desc: double
+#% description: Thermal conductivity of the borehole filling (geothermal grout) [W m-1 K-1]
+#% required: no
+#% answer: 2
+#% guisection: BHE
+#%end
+
+#%option
+#% key: fluid_limit_temperature
+#% type: double
+#% key_desc: double
+#% description: Minimum or maximum fluid temperature [°C]
+#% required: no
+#% answer: -2
+#% guisection: BHE
+#%end
+
+#%option
+#% key: lifetime
+#% type: integer
+#% key_desc: integer
+#% description:  Simulated lifetime of the plant [years]
+#% required: no
+#% answer: 50
+#% guisection: BHE
+#%end
+
+#%option G_OPT_R_OUTPUT
+#% key: power
+#% type: string
+#% key_desc: name
+#% description: Name of output raster map with the geothermal power potential [W]
+#% required: yes
+#%end
+
+#%option G_OPT_R_OUTPUT
+#% key: energy
+#% type: string
+#% key_desc: name
+#% description: Name of output raster map with the geothermal energy potential [MWh]
+#% required: yes
+#%end
+
+#%option G_OPT_R_OUTPUT
+#% key: length
+#% type: string
+#% key_desc: name
+#% description: Name of output raster map with the geothermal length of the BHE [m]
+#% required: no
+#%end
+
+#%flag
+#% key: d
+#% description: Debug with intermediate maps
+#%end
+
+from __future__ import print_function
+
+import os
+import sys
+import atexit
+
+# import grass libraries
+from grass.script import core as gcore
+from grass.pygrass.utils import set_path
+
+try:
+    # set python path to the shared r.green libraries
+    set_path('r.green', 'libgshp', '..')
+    set_path('r.green', 'libgreen', os.path.join('..', '..'))
+    from libgreen.utils import cleanup
+    from libgshp import gpot
+except ImportError:
+    try:
+        set_path('r.green', 'libgshp', os.path.join('..', 'etc', 'r.green'))
+        set_path('r.green', 'libgreen', os.path.join('..', 'etc', 'r.green'))
+        from libgreen.utils import cleanup
+        from libgshp import gpot
+    except ImportError:
+        gcore.warning('libgreen and libhydro not in the python path!')
+
+
+def rast_or_numb(rast, numb, opts):
+    """Return a float or a string with the raster name.
+    """
+    return opts[rast] if opts[rast] else float(opts[numb])
+
+
+def main(opts, flgs):
+    """
+    Parameters
+    ----------
+    heating_season: int [days]
+        Number of heating days, default: 180 days
+    ground_conductivity: float [W m-1 K-1]
+        Depth averaged thermal conductivity
+    ground_capacity: float []
+        Depth averaged thermal capacity
+    lifetime: int [years]
+        Simulated lifetime of the plant, default: 50 years
+    borehole_radius: float [m]
+        Borehole radius
+    pipe_radius: float [m]
+        Pipe radius, default:
+    number_pipes: int
+        Number of pipes in the borehole, default: 4
+    grout_conductivity: [W m-1 K-1]
+        Thermal conductivity of the borehole filling (geothermal grout).
+        Default: 2
+    borehole_resistence: [m K W-1]
+        Borehole thermal resistence
+    borehole_length: [m]
+        Borehole length, default: 100m
+    ground_temperature: [°C]
+        Initial ground temperature, default: 10 °C
+    fluid_limit_temperature: [°C]
+        Minimum or maximum fluid temperature, default: -2 °C
+    """
+    pid = os.getpid()
+    DEBUG = flags['d']
+    OVER = gcore.overwrite()
+    tmpbase = "tmprgreen_%i" % pid
+    atexit.register(gpot.cleanup, pattern=(tmpbase + '*'), debug=DEBUG)
+
+    heating_season = float(opts['heating_season']) * 24 * 60 * 60
+    lifetime = float(opts['lifetime']) * 365 * 24 * 60 * 60
+
+    # ================================================
+    # GROUND
+    # get raster or scalar value
+    ground_conductivity = opts['ground_conductivity']
+    ground_capacity = rast_or_numb('ground_capacity_rast',
+                                   'ground_capacity_value', opts)
+    ground_temperature = rast_or_numb('ground_temp_rast',
+                                      'ground_temp_value', opts)
+
+    # ================================================
+    # BHE
+    pipe_radius = float(opts['pipe_radius'])
+    number_pipes = float(opts['number_pipes'])
+    grout_conductivity = float(opts['grout_conductivity'])
+    fluid_limit_temperature = float(opts['fluid_limit_temperature'])
+
+    # ================================================s
+    # BOREHOLE
+    borehole_radius = float(opts['borehole_radius'])
+    borehole_length = float(opts['borehole_length'])
+    if opts['borehole_resistence'] == 'nan':
+        borehole_resistence = gpot.get_borehole_resistence(borehole_radius,
+                                                           pipe_radius,
+                                                           number_pipes,
+                                                           grout_conductivity)
+    else:
+        borehole_resistence = float(opts['borehole_resistence'])
+
+    # START COMPUTATIONS
+    uc = tmpbase + '_uc'
+    gpot.r_norm_time(uc, heating_season, borehole_radius,
+                     ground_conductivity, ground_capacity, overwrite=OVER)
+    us = tmpbase + '_us'
+    gpot.r_norm_time(us, lifetime, borehole_radius,
+                     ground_conductivity, ground_capacity, overwrite=OVER)
+
+    gmax = tmpbase + '_gmax'
+    tc = heating_season / (365. * 24 * 60 * 60.)
+    gpot.r_norm_thermal_alteration(gmax, tc, uc, us, execute=True,
+                                   overwrite=OVER)
+
+    power = opts['power']
+    gpot.r_power(power, tc, ground_conductivity, ground_temperature,
+                 fluid_limit_temperature, borehole_length, borehole_resistence,
+                 gmax, execute=True, overwrite=OVER)
+
+    energy = opts['energy']
+    gpot.r_energy(energy, power, execute=True, overwrite=OVER)
+
+
+if __name__ == "__main__":
+    options, flags = gcore.parser()
+    main(options, flags)
+    sys.exit(0)


Property changes on: grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native



More information about the grass-commit mailing list