diff --git a/Two-phase-Richards/multi-patch/layered_soil/TP-R-layered_soil-all-params-one.py b/Two-phase-Richards/multi-patch/layered_soil/TP-R-layered_soil-all-params-one.py
index 6ed51c148d6a099403dc3a23d92544749c920aa2..5d8414f543fa5fb98cb608c13e98460e8a9394e1 100755
--- a/Two-phase-Richards/multi-patch/layered_soil/TP-R-layered_soil-all-params-one.py
+++ b/Two-phase-Richards/multi-patch/layered_soil/TP-R-layered_soil-all-params-one.py
@@ -41,7 +41,7 @@ resolutions = {
 # GRID #######################
 # mesh_resolution = 20
 timestep_size = 0.001
-number_of_timesteps = 12
+number_of_timesteps = 1200
 plot_timestep_every = 4
 # decide how many timesteps you want analysed. Analysed means, that we write
 # out subsequent errors of the L-iteration within the timestep.
diff --git a/Two-phase-Richards/multi-patch/layered_soil/TP-R-layered_soil.py b/Two-phase-Richards/multi-patch/layered_soil/TP-R-layered_soil.py
index b08b8b70adb5898285c712cf4cf1b11fcb536c45..024176e6bdb6a1ad6282eea931d60b3a5a8e782a 100755
--- a/Two-phase-Richards/multi-patch/layered_soil/TP-R-layered_soil.py
+++ b/Two-phase-Richards/multi-patch/layered_soil/TP-R-layered_soil.py
@@ -1,20 +1,16 @@
 #!/usr/bin/python3
-"""This program sets up a domain together with a decomposition into subdomains
-modelling layered soil. This is used for our LDD article with tp-tp and tp-r
-coupling.
+"""Layered soil simulation.
 
-Along with the subdomains and the mesh domain markers are set upself.
-The resulting mesh is saved into files for later use.
+This program sets up an LDD simulation
 """
 
-#!/usr/bin/python3
 import dolfin as df
-import mshr
-import numpy as np
+# import mshr
+# import numpy as np
 import sympy as sym
-import typing as tp
+# import typing as tp
 import functools as ft
-import domainPatch as dp
+# import domainPatch as dp
 import LDDsimulation as ldd
 import helpers as hlp
 import datetime
@@ -28,7 +24,7 @@ datestr = date.strftime("%Y-%m-%d")
 sym.init_printing()
 # solver_tol = 6E-7
 use_case = "TP-R-layered-soil-all-params-set-one"
-max_iter_num = 1000
+max_iter_num = 500
 FEM_Lagrange_degree = 1
 mesh_study = False
 resolutions = {
@@ -36,38 +32,42 @@ resolutions = {
                 # 2: 2e-5,  # h=1.1180
                 # 4: 1e-6,  # h=0.5590
                 # 8: 1e-6,  # h=0.2814
-                16: 1e-6, # h=0.1412
-                # 32: 1e-6,
+                # 16: 1e-6, # h=0.1412
+                32: 1e-6,
                 # 64: 5e-7,
                 # 128: 5e-7
                 }
 
-############ GRID #######################
+# GRID #######################
 # mesh_resolution = 20
 timestep_size = 0.001
-number_of_timesteps = 40
-plot_timestep_every = 1
-# decide how many timesteps you want analysed. Analysed means, that we write out
-# subsequent errors of the L-iteration within the timestep.
-number_of_timesteps_to_analyse = 0
+number_of_timesteps = 1200
+plot_timestep_every = 4
+# decide how many timesteps you want analysed. Analysed means, that we write
+# out subsequent errors of the L-iteration within the timestep.
+number_of_timesteps_to_analyse = 6
 starttimes = [0.0]
 
-Lw = 0.025 #/timestep_size
-Lnw=Lw
+Lw = 0.025  # /timestep_size
+Lnw = Lw
 
 lambda_w = 40
 lambda_nw = 40
 
 include_gravity = True
-debugflag = False
+debugflag = True
 analyse_condition = False
 
 if mesh_study:
-    output_string = "./output/{}-{}_timesteps{}_P{}".format(datestr, use_case, number_of_timesteps, FEM_Lagrange_degree)
+    output_string = "./output/{}-{}_timesteps{}_P{}".format(
+        datestr, use_case, number_of_timesteps, FEM_Lagrange_degree
+        )
 else:
     for tol in resolutions.values():
         solver_tol = tol
-    output_string = "./output/{}-{}_timesteps{}_P{}_solver_tol{}".format(datestr, use_case, number_of_timesteps, FEM_Lagrange_degree, solver_tol)
+    output_string = "./output/{}-{}_timesteps{}_P{}_solver_tol{}".format(
+        datestr, use_case, number_of_timesteps, FEM_Lagrange_degree, solver_tol
+        )
 
 
 # toggle what should be written to files
@@ -92,11 +92,15 @@ else:
         'subsequent_errors': True
     }
 
+
 # global domain
-subdomain0_vertices = [df.Point(-1.0,-1.0), #
-                        df.Point(1.0,-1.0),#
-                        df.Point(1.0,1.0),#
-                        df.Point(-1.0,1.0)]
+subdomain0_vertices = [
+    df.Point(-1.0, -1.0),
+    df.Point(1.0, -1.0),
+    df.Point(1.0, 1.0),
+    df.Point(-1.0, 1.0)
+    ]
+
 
 interface12_vertices = [df.Point(-1.0, 0.8),
                         df.Point(0.3, 0.8),
@@ -104,50 +108,56 @@ interface12_vertices = [df.Point(-1.0, 0.8),
                         df.Point(0.8, 0.7),
                         df.Point(1.0, 0.65)]
 # subdomain1.
-subdomain1_vertices = [interface12_vertices[0],
-                        interface12_vertices[1],
-                        interface12_vertices[2],
-                        interface12_vertices[3],
-                        interface12_vertices[4], # southern boundary, 12 interface
-                        subdomain0_vertices[2], # eastern boundary, outer boundary
-                        subdomain0_vertices[3]] # northern boundary, outer on_boundary
+subdomain1_vertices = [
+    interface12_vertices[0],
+    interface12_vertices[1],
+    interface12_vertices[2],
+    interface12_vertices[3],
+    interface12_vertices[4],  # southern boundary, 12 interface
+    subdomain0_vertices[2],  # eastern boundary, outer boundary
+    subdomain0_vertices[3]  # northern boundary, outer on_boundary
+    ]
+
 
 # vertex coordinates of the outer boundaries. If it can not be specified as a
-# polygon, use an entry per boundary polygon. This information is used for defining
-# the Dirichlet boundary conditions. If a domain is completely internal, the
-# dictionary entry should be 0: None
+# polygon, use an entry per boundary polygon. This information is used for
+# defining the Dirichlet boundary conditions. If a domain is completely
+# internal, the dictionary entry should be 0: None
 subdomain1_outer_boundary_verts = {
-    0: [interface12_vertices[4], #
-        subdomain0_vertices[2], # eastern boundary, outer boundary
+    0: [interface12_vertices[4],
+        subdomain0_vertices[2],  # eastern boundary, outer boundary
         subdomain0_vertices[3],
         interface12_vertices[0]]
 }
 
 
 # interface23
-interface23_vertices = [df.Point(-1.0, 0.0),
-                        df.Point(-0.35, 0.0),
-                        # df.Point(6.5, 4.5),
-                        df.Point(0.0, 0.0),
-                        df.Point(0.5, 0.0),
-                        # df.Point(11.5, 3.5),
-                        # df.Point(13.0, 3)
-                        df.Point(0.85, 0.0),
-                        df.Point(1.0, 0.0)
-                        ]
-
-#subdomain1
-subdomain2_vertices = [interface23_vertices[0],
-                        interface23_vertices[1],
-                        interface23_vertices[2],
-                        interface23_vertices[3],
-                        interface23_vertices[4],
-                        interface23_vertices[5], # southern boundary, 23 interface
-                        subdomain1_vertices[4], # eastern boundary, outer boundary
-                        subdomain1_vertices[3],
-                        subdomain1_vertices[2],
-                        subdomain1_vertices[1],
-                        subdomain1_vertices[0] ] # northern boundary, 12 interface
+interface23_vertices = [
+    df.Point(-1.0, 0.0),
+    df.Point(-0.35, 0.0),
+    # df.Point(6.5, 4.5),
+    df.Point(0.0, 0.0),
+    df.Point(0.5, 0.0),
+    # df.Point(11.5, 3.5),
+    # df.Point(13.0, 3)
+    df.Point(0.85, 0.0),
+    df.Point(1.0, 0.0)
+    ]
+
+# subdomain1
+subdomain2_vertices = [
+    interface23_vertices[0],
+    interface23_vertices[1],
+    interface23_vertices[2],
+    interface23_vertices[3],
+    interface23_vertices[4],
+    interface23_vertices[5],  # southern boundary, 23 interface
+    subdomain1_vertices[4],  # eastern boundary, outer boundary
+    subdomain1_vertices[3],
+    subdomain1_vertices[2],
+    subdomain1_vertices[1],
+    subdomain1_vertices[0]  # northern boundary, 12 interface
+    ]
 
 subdomain2_outer_boundary_verts = {
     0: [interface23_vertices[5],
@@ -165,17 +175,19 @@ interface34_vertices = [df.Point(-1.0, -0.6),
                         df.Point(1.0, -0.7)]
 
 # subdomain3
-subdomain3_vertices = [interface34_vertices[0],
-                        interface34_vertices[1],
-                        interface34_vertices[2],
-                        interface34_vertices[3],
-                        interface34_vertices[4], # southern boundary, 34 interface
-                        subdomain2_vertices[5], # eastern boundary, outer boundary
-                        subdomain2_vertices[4],
-                        subdomain2_vertices[3],
-                        subdomain2_vertices[2],
-                        subdomain2_vertices[1],
-                        subdomain2_vertices[0] ] # northern boundary, 23 interface
+subdomain3_vertices = [
+    interface34_vertices[0],
+    interface34_vertices[1],
+    interface34_vertices[2],
+    interface34_vertices[3],
+    interface34_vertices[4],  # southern boundary, 34 interface
+    subdomain2_vertices[5],  # eastern boundary, outer boundary
+    subdomain2_vertices[4],
+    subdomain2_vertices[3],
+    subdomain2_vertices[2],
+    subdomain2_vertices[1],
+    subdomain2_vertices[0]  # northern boundary, 23 interface
+    ]
 
 subdomain3_outer_boundary_verts = {
     0: [interface34_vertices[4],
@@ -185,13 +197,16 @@ subdomain3_outer_boundary_verts = {
 }
 
 # subdomain4
-subdomain4_vertices = [subdomain0_vertices[0],
-                        subdomain0_vertices[1], # southern boundary, outer boundary
-                        subdomain3_vertices[4],# eastern boundary, outer boundary
-                        subdomain3_vertices[3],
-                        subdomain3_vertices[2],
-                        subdomain3_vertices[1],
-                        subdomain3_vertices[0] ] # northern boundary, 34 interface
+subdomain4_vertices = [
+    subdomain0_vertices[0],
+    subdomain0_vertices[1],  # southern boundary, outer boundary
+    subdomain3_vertices[4],  # eastern boundary, outer boundary
+    subdomain3_vertices[3],
+    subdomain3_vertices[2],
+    subdomain3_vertices[1],
+    subdomain3_vertices[0]
+    ]  # northern boundary, 34 interface
+
 
 subdomain4_outer_boundary_verts = {
     0: [subdomain4_vertices[6],
@@ -201,17 +216,20 @@ subdomain4_outer_boundary_verts = {
 }
 
 
-subdomain_def_points = [subdomain0_vertices,#
-                      subdomain1_vertices,#
-                      subdomain2_vertices,#
-                      subdomain3_vertices,#
-                      subdomain4_vertices
-                      ]
-
+subdomain_def_points = [
+    subdomain0_vertices,
+    subdomain1_vertices,
+    subdomain2_vertices,
+    subdomain3_vertices,
+    subdomain4_vertices
+    ]
 
 # interface_vertices introduces a global numbering of interfaces.
-interface_def_points = [interface12_vertices, interface23_vertices, interface34_vertices]
-adjacent_subdomains = [[1,2], [2,3], [3,4]]
+interface_def_points = [
+    interface12_vertices, interface23_vertices, interface34_vertices
+    ]
+
+adjacent_subdomains = [[1, 2], [2, 3], [3, 4]]
 
 # if a subdomain has no outer boundary write None instead, i.e.
 # i: None
@@ -240,61 +258,62 @@ isRichards = {
 
 # Dict of the form: { subdom_num : viscosity }
 viscosity = {
-    1: {'wetting' :1,
-         'nonwetting': 1},
-    2: {'wetting' :1,
-         'nonwetting': 1},
-    3: {'wetting' :1,
-         'nonwetting': 1},
-    4: {'wetting' :1,
-         'nonwetting': 1},
+    1: {'wetting': 1,
+        'nonwetting': 1},
+    2: {'wetting': 1,
+        'nonwetting': 1},
+    3: {'wetting': 1,
+        'nonwetting': 1},
+    4: {'wetting': 1,
+        'nonwetting': 1},
 }
 
 # Dict of the form: { subdom_num : density }
 densities = {
-    1: {'wetting': 1,  #997
-         'nonwetting':1},  #1.225}},
-    2: {'wetting': 1,  #997
-         'nonwetting':1},  #1.225}},
-    3: {'wetting': 1,  #997
-         'nonwetting':1},  #1.225}},
-    4: {'wetting': 1,  #997
-         'nonwetting':1},  #1.225}}
+    1: {'wetting': 1,  # 997
+        'nonwetting': 1},  # 1.225}},
+    2: {'wetting': 1,  # 997
+        'nonwetting': 1},  # 1.225}},
+    3: {'wetting': 1,  # 997
+        'nonwetting': 1},  # 1.225}},
+    4: {'wetting': 1,  # 997
+        'nonwetting': 1},  # 1.225}}
 }
 
+
 gravity_acceleration = 1
 # porosities taken from
 # https://www.geotechdata.info/parameter/soil-porosity.html
 # Dict of the form: { subdom_num : porosity }
 porosity = {
-    1: 1,  #0.2,  # Clayey gravels, clayey sandy gravels
-    2: 1,  #0.22, # Silty gravels, silty sandy gravels
-    3: 1,  #0.37, # Clayey sands
-    4: 1,  #0.2 # Silty or sandy clay
+    1: 1,  # 0.2,  # Clayey gravels, clayey sandy gravels
+    2: 1,  # 0.22, # Silty gravels, silty sandy gravels
+    3: 1,  # 0.37, # Clayey sands
+    4: 1,  # 0.2 # Silty or sandy clay
 }
 
 # subdom_num : subdomain L for L-scheme
 L = {
-    1: {'wetting' :Lw,
-         'nonwetting': Lnw},
-    2: {'wetting' :Lw,
-         'nonwetting': Lnw},
-    3: {'wetting' :Lw,
-         'nonwetting': Lnw},
-    4: {'wetting' :Lw,
-         'nonwetting': Lnw}
+    1: {'wetting': Lw,
+        'nonwetting': Lnw},
+    2: {'wetting': Lw,
+        'nonwetting': Lnw},
+    3: {'wetting': Lw,
+        'nonwetting': Lnw},
+    4: {'wetting': Lw,
+        'nonwetting': Lnw}
 }
 
 # subdom_num : lambda parameter for the L-scheme
 lambda_param = {
     1: {'wetting': lambda_w,
-         'nonwetting': lambda_nw},#
+        'nonwetting': lambda_nw},
     2: {'wetting': lambda_w,
-         'nonwetting': lambda_nw},#
+        'nonwetting': lambda_nw},
     3: {'wetting': lambda_w,
-         'nonwetting': lambda_nw},#
+        'nonwetting': lambda_nw},
     4: {'wetting': lambda_w,
-         'nonwetting': lambda_nw},#
+        'nonwetting': lambda_nw},
 }
 
 intrinsic_permeability = {
@@ -304,7 +323,8 @@ intrinsic_permeability = {
     4: 1
 }
 
-## relative permeabilty functions on subdomain 1
+
+# relative permeabilty functions on subdomain 1
 def rel_perm1w(s):
     # relative permeabilty wetting on subdomain1
     return intrinsic_permeability[1]*s**2
@@ -315,14 +335,14 @@ def rel_perm1nw(s):
     return intrinsic_permeability[1]*(1-s)**2
 
 
-## relative permeabilty functions on subdomain 2
+# relative permeabilty functions on subdomain 2
 def rel_perm2w(s):
     # relative permeabilty wetting on subdomain2
     return intrinsic_permeability[2]*s**3
 
 
 def rel_perm2nw(s):
-    # relative permeabilty nonwetting on subdosym.cos(0.8*t - (0.8*x + 1/7*y))main2
+    # relative permeabilty nonwetting on subdomain2
     return intrinsic_permeability[2]*(1-s)**3
 
 
@@ -332,12 +352,12 @@ _rel_perm2w = ft.partial(rel_perm2w)
 _rel_perm2nw = ft.partial(rel_perm2nw)
 
 subdomain1_rel_perm = {
-    'wetting': _rel_perm1w,#
+    'wetting': _rel_perm1w,
     'nonwetting': _rel_perm1nw
 }
 
 subdomain2_rel_perm = {
-    'wetting': _rel_perm2w,#
+    'wetting': _rel_perm2w,
     'nonwetting': _rel_perm2nw
 }
 
@@ -355,26 +375,31 @@ relative_permeability = {
     4: subdomain2_rel_perm
 }
 
+
 # definition of the derivatives of the relative permeabilities
 # relative permeabilty functions on subdomain 1
 def rel_perm1w_prime(s):
     # relative permeabilty on subdomain1
     return intrinsic_permeability[1]*2*s
 
+
 def rel_perm1nw_prime(s):
     # relative permeabilty on subdomain1
     return -1*intrinsic_permeability[1]*2*(1-s)
 
+
 # definition of the derivatives of the relative permeabilities
 # relative permeabilty functions on subdomain 1
 def rel_perm2w_prime(s):
     # relative permeabilty on subdomain1
     return intrinsic_permeability[2]*3*s**2
 
+
 def rel_perm2nw_prime(s):
     # relative permeabilty on subdomain1
     return -1*intrinsic_permeability[2]*3*(1-s)**2
 
+
 _rel_perm1w_prime = ft.partial(rel_perm1w_prime)
 _rel_perm1nw_prime = ft.partial(rel_perm1nw_prime)
 _rel_perm2w_prime = ft.partial(rel_perm2w_prime)
@@ -400,24 +425,27 @@ ka_prime = {
 }
 
 
-
-# S-pc-relation ship. We use the van Genuchten approach, i.e. pc = 1/alpha*(S^{-1/m} -1)^1/n, where
-# we set alpha = 0, assume m = 1-1/n (see Helmig) and assume that residual saturation is Sw
-# this function needs to be monotonically decreasing in the capillary pressure pc.
-# since in the richards case pc=-pw, this becomes as a function of pw a mono
-# tonically INCREASING function like in our Richards-Richards paper. However
-# since we unify the treatment in the code for Richards and two-phase, we need
-# the same requierment
-# for both cases, two-phase and Richards.
+# S-pc-relation ship. We use the van Genuchten approach, i.e.
+# pc = 1/alpha*(S^{-1/m} -1)^1/n, where we set alpha = 0, assume m = 1-1/n
+# (see Helmig) and assume that residual saturation is Sw
+# this function needs to be monotonically decreasing in the capillary pressure
+# pc. Since in the richards case pc=-pw, this becomes as a function of pw a
+# mono tonically INCREASING function like in our Richards-Richards paper.
+# However since we unify the treatment in the code for Richards and two-phase,
+# we need the same requierment for both cases, two-phase and Richards.
 def saturation(pc, n_index, alpha):
     # inverse capillary pressure-saturation-relationship
-    return df.conditional(pc > 0, 1/((1 + (alpha*pc)**n_index)**((n_index - 1)/n_index)), 1)
+    expr = df.conditional(
+        pc > 0, 1/((1 + (alpha*pc)**n_index)**((n_index - 1)/n_index)), 1)
+    return expr
+
 
-# S-pc-relation ship. We use the van Genuchten approach, i.e. pc = 1/alpha*(S^{-1/m} -1)^1/n, where
-# we set alpha = 0, assume m = 1-1/n (see Helmig) and assume that residual saturation is Sw
+# S-pc-relation ship. We use the van Genuchten approach, i.e.
+# pc = 1/alpha*(S^{-1/m} -1)^1/n, where we set alpha = 0, assume m = 1-1/n
+# (see Helmig) and assume that residual saturation is Sw
 def saturation_sym(pc, n_index, alpha):
     # inverse capillary pressure-saturation-relationship
-    #df.conditional(pc > 0,
+    # df.conditional(pc > 0,
     return 1/((1 + (alpha*pc)**n_index)**((n_index - 1)/n_index))
 
 
@@ -425,7 +453,9 @@ def saturation_sym(pc, n_index, alpha):
 # construction of a analytic solution.
 def saturation_sym_prime(pc, n_index, alpha):
     # inverse capillary pressure-saturation-relationship
-    return -(alpha*(n_index - 1)*(alpha*pc)**(n_index - 1)) / ( (1 + (alpha*pc)**n_index)**((2*n_index - 1)/n_index) )
+    expr = -(alpha*(n_index - 1)*(alpha*pc)**(n_index - 1))\
+        / ((1 + (alpha*pc)**n_index)**((2*n_index - 1)/n_index))
+    return expr
 
 
 # note that the conditional definition of S-pc in the nonsymbolic part will be
@@ -437,6 +467,7 @@ S_pc_sym = {
     4: ft.partial(saturation_sym, n_index=6, alpha=0.001)
 }
 
+
 S_pc_sym_prime = {
     1: ft.partial(saturation_sym_prime, n_index=3, alpha=0.001),
     2: ft.partial(saturation_sym_prime, n_index=3, alpha=0.001),
@@ -444,6 +475,7 @@ S_pc_sym_prime = {
     4: ft.partial(saturation_sym_prime, n_index=6, alpha=0.001)
 }
 
+
 sat_pressure_relationship = {
     1: ft.partial(saturation, n_index=3, alpha=0.001),
     2: ft.partial(saturation, n_index=3, alpha=0.001),
@@ -460,7 +492,7 @@ t = sym.symbols('t', positive=True)
 
 p_e_sym_2patch = {
     1: {'wetting': -7 - (1+t*t)*(1 + x*x + y*y),
-        'nonwetting': 0.0*t}, #-1-t*(1.1 + y + x**2)**2},
+        'nonwetting': 0.0*t},  # -1-t*(1.1 + y + x**2)**2},
     2: {'wetting': -7.0 - (1.0 + t*t)*(1.0 + x*x),
         'nonwetting': (-1-t*(1.1 + x**2)**2 - sym.sqrt(5+t**2))*y**2},
 }
@@ -479,13 +511,25 @@ p_e_sym = {
 
 # p_e_sym = {
 #     1: {'wetting': 1.0 - (1.0 + t*t)*(10.0 + x*x + (y-5.0)*(y-5.0)),
-#         'nonwetting': - 2 - t*(1 + (y-5.0) + x**2)**2 -sym.sqrt(2+t**2)*(1 + (y-5.0)) },
+#         'nonwetting':
+#             -2 - t*(1 + (y - 5.0) + x**2)**2
+#             - sym.sqrt(2 + t**2)*(1 + (y - 5.0))
+#         },
 #     2: {'wetting': 1.0 - (1.0 + t*t)*(10.0 + x*x + (y-5.0)*(y-5.0)),
-#         'nonwetting': - 2 - t*(1 + (y-5.0) + x**2)**2 -sym.sqrt(2+t**2)*(1 + (y-5.0))},
-#     3: {'wetting': 1.0 - (1.0 + t*t)*(10.0 + x*x + (y-5.0)*(y-5.0)) - (y-5.0)*(y-5.0)*3*sym.sin(-2*t+2*x)*sym.sin(1/2*y-1.2*t),
-#         'nonwetting': - 2 - t*(1 + x**2)**2 -sym.sqrt(2+t**2)},
-#     4: {'wetting': 1.0 - (1.0 + t*t)*(10.0 + x*x + (y-5.0)*(y-5.0)) - (y-5.0)*(y-5.0)*3*sym.sin(-2*t+2*x)*sym.sin(1/2*y-1.2*t),
-#         'nonwetting': - 2 - t*(1 + x**2)**2 -sym.sqrt(2+t**2)}
+#         'nonwetting':
+#             - 2 - t*(1 + (y - 5.0) + x**2)**2
+#             - sym.sqrt(2 + t**2)*(1 + (y - 5.0))
+#         },
+#     3: {'wetting':
+#             1.0 - (1.0 + t*t)*(10.0 + x*x + (y - 5.0)*(y - 5.0))
+#             - (y - 5.0)*(y - 5.0)*3*sym.sin(-2*t + 2*x)*sym.sin(1/2*y - 1.2*t),
+#         'nonwetting': - 2 - t*(1 + x**2)**2 - sym.sqrt(2 + t**2)
+#         },
+#     4: {'wetting':
+#         1.0 - (1.0 + t*t)*(10.0 + x*x + (y - 5.0)*(y - 5.0))
+#         - (y - 5.0)*(y - 5.0)*3*sym.sin(-2*t + 2*x)*sym.sin(1/2*y - 1.2*t),
+#         'nonwetting': - 2 - t*(1 + x**2)**2 - sym.sqrt(2 + t**2)
+#         }
 # }
 
 pc_e_sym = dict()
@@ -493,8 +537,10 @@ for subdomain, isR in isRichards.items():
     if isR:
         pc_e_sym.update({subdomain: -p_e_sym[subdomain]['wetting']})
     else:
-        pc_e_sym.update({subdomain: p_e_sym[subdomain]['nonwetting']
-                                        - p_e_sym[subdomain]['wetting']})
+        pc_e_sym.update(
+            {subdomain: p_e_sym[subdomain]['nonwetting']
+                - p_e_sym[subdomain]['wetting']}
+            )
 
 
 symbols = {"x": x,
@@ -537,7 +583,8 @@ dirichletBC = dict()
 
 # subdomain index: {outer boudary part index: {phase: expression}}
 for subdomain in isRichards.keys():
-    # if subdomain has no outer boundary, outer_boundary_def_points[subdomain] is None
+    # if subdomain has no outer boundary, outer_boundary_def_points[subdomain]
+    # is None
     if outer_boundary_def_points[subdomain] is None:
         dirichletBC.update({subdomain: None})
     else:
@@ -568,33 +615,34 @@ for starttime in starttimes:
             mesh_study=mesh_study
             )
 
-        simulation.set_parameters(use_case=use_case,
-                                  output_dir=output_string,
-                                  subdomain_def_points=subdomain_def_points,
-                                  isRichards=isRichards,
-                                  interface_def_points=interface_def_points,
-                                  outer_boundary_def_points=outer_boundary_def_points,
-                                  adjacent_subdomains=adjacent_subdomains,
-                                  mesh_resolution=mesh_resolution,
-                                  viscosity=viscosity,
-                                  porosity=porosity,
-                                  L=L,
-                                  lambda_param=lambda_param,
-                                  relative_permeability=relative_permeability,
-                                  saturation=sat_pressure_relationship,
-                                  starttime=starttime,
-                                  number_of_timesteps=number_of_timesteps,
-                                  number_of_timesteps_to_analyse=number_of_timesteps_to_analyse,
-                                  plot_timestep_every=plot_timestep_every,
-                                  timestep_size=timestep_size,
-                                  sources=source_expression,
-                                  initial_conditions=initial_condition,
-                                  dirichletBC_expression_strings=dirichletBC,
-                                  exact_solution=exact_solution,
-                                  densities=densities,
-                                  include_gravity=include_gravity,
-                                  write2file=write_to_file,
-                                  )
+        simulation.set_parameters(
+            use_case=use_case,
+            output_dir=output_string,
+            subdomain_def_points=subdomain_def_points,
+            isRichards=isRichards,
+            interface_def_points=interface_def_points,
+            outer_boundary_def_points=outer_boundary_def_points,
+            adjacent_subdomains=adjacent_subdomains,
+            mesh_resolution=mesh_resolution,
+            viscosity=viscosity,
+            porosity=porosity,
+            L=L,
+            lambda_param=lambda_param,
+            relative_permeability=relative_permeability,
+            saturation=sat_pressure_relationship,
+            starttime=starttime,
+            number_of_timesteps=number_of_timesteps,
+            number_of_timesteps_to_analyse=number_of_timesteps_to_analyse,
+            plot_timestep_every=plot_timestep_every,
+            timestep_size=timestep_size,
+            sources=source_expression,
+            initial_conditions=initial_condition,
+            dirichletBC_expression_strings=dirichletBC,
+            exact_solution=exact_solution,
+            densities=densities,
+            include_gravity=include_gravity,
+            write2file=write_to_file,
+            )
 
         simulation.initialise()
         output_dir = simulation.output_dir
@@ -602,26 +650,39 @@ for starttime in starttimes:
         output = simulation.run(analyse_condition=analyse_condition)
         for subdomain_index, subdomain_output in output.items():
             mesh_h = subdomain_output['mesh_size']
-            for phase, different_errornorms in subdomain_output['errornorm'].items():
-                filename = output_dir + "subdomain{}-space-time-errornorm-{}-phase.csv".format(subdomain_index, phase)
-                # for errortype, errornorm in different_errornorms.items():
-
-                    # eocfile = open("eoc_filename", "a")
-                    # eocfile.write( str(mesh_h) + " " + str(errornorm) + "\n" )
-                    # eocfile.close()
-                    # if subdomain.isRichards:mesh_h
+            for phase, error_dict in subdomain_output['errornorm'].items():
+                filename = output_dir \
+                    + "subdomain{}".format(subdomain_index)\
+                    + "-space-time-errornorm-{}-phase.csv".format(phase)
+                # for errortype, errornorm in error_dict.items():
+
+                # eocfile = open("eoc_filename", "a")
+                # eocfile.write( str(mesh_h) + " " + str(errornorm) + "\n" )
+                # eocfile.close()
+                # if subdomain.isRichards:mesh_h
                 data_dict = {
                     'mesh_parameter': mesh_resolution,
                     'mesh_h': mesh_h,
                 }
-                for error_type, errornorms in different_errornorms.items():
+                for norm_type, errornorm in error_dict.items():
                     data_dict.update(
-                        {error_type: errornorms}
+                        {norm_type: errornorm}
                     )
                 errors = pd.DataFrame(data_dict, index=[mesh_resolution])
                 # check if file exists
-                if os.path.isfile(filename) == True:
+                if os.path.isfile(filename) is True:
                     with open(filename, 'a') as f:
-                        errors.to_csv(f, header=False, sep='\t', encoding='utf-8', index=False)
+                        errors.to_csv(
+                            f,
+                            header=False,
+                            sep='\t',
+                            encoding='utf-8',
+                            index=False
+                            )
                 else:
-                    errors.to_csv(filename, sep='\t', encoding='utf-8', index=False)
+                    errors.to_csv(
+                        filename,
+                        sep='\t',
+                        encoding='utf-8',
+                        index=False
+                        )