|
| 1 | +abstract class GeoObject (hidden GeoObject above, |
| 2 | + hidden GeoObject below, |
| 3 | + hidden GeoObject left, |
| 4 | + hidden GeoObject right, |
| 5 | + hidden GeoObject behind, |
| 6 | + hidden GeoObject front, |
| 7 | + hidden Double size) |
| 8 | + Double getSizeAbove() |
| 9 | + if(this.above == null) then return 0.0; |
| 10 | + else |
| 11 | + Double a = this.above.size; |
| 12 | + Double b = this.above.getSizeAbove(); |
| 13 | + return a+b; |
| 14 | + end |
| 15 | + end |
| 16 | + abstract Unit update() |
| 17 | + Unit updateAll() |
| 18 | + this.update(); |
| 19 | + if(this.above != null) then |
| 20 | + this.above.updateAll(); |
| 21 | + end |
| 22 | + end |
| 23 | + abstract Boolean caps() |
| 24 | + abstract Unit addUnit() |
| 25 | + abstract Unit printState() |
| 26 | +end |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +class Fault extends GeoObject () |
| 31 | + override Unit update() |
| 32 | + skip; |
| 33 | + end |
| 34 | + override Unit addUnit() |
| 35 | + skip; |
| 36 | + end |
| 37 | + override Boolean caps() |
| 38 | + return False; |
| 39 | + end |
| 40 | + override Unit printState() |
| 41 | + skip; |
| 42 | + end |
| 43 | + |
| 44 | +end |
| 45 | + |
| 46 | + |
| 47 | +abstract class GeoUnit extends GeoObject (hidden Int mergeId) |
| 48 | + abstract GeoUnit clone() |
| 49 | + /*@ requires other != null @*/ |
| 50 | + Boolean canMerge(GeoUnit other) |
| 51 | + return other.mergeId == this.mergeId; |
| 52 | + end |
| 53 | + |
| 54 | + /*@ requires other != null @*/ |
| 55 | + Unit mergeWith(GeoUnit other) |
| 56 | + this.size = this.size + other.size; |
| 57 | + end |
| 58 | +end |
| 59 | + |
| 60 | +class ChalkUnit extends GeoUnit (List<Double> kerogenUnits) |
| 61 | + models "a <http://purl.obolibrary.org/obo/bfo.owl#UFRGS:GeoCoreOntology_geological_object>; <http://purl.obolibrary.org/obo/bfo.owl#UFRGS:GeoCoreOntology_constituted_by> _:fr1. _:fr1 a domain:chalk. "; |
| 62 | + |
| 63 | + override Unit update() |
| 64 | + List<Double> l = this.kerogenUnits; |
| 65 | + while l != null do |
| 66 | + Double next = l.content; |
| 67 | + if next >= 0 then |
| 68 | + if next + 100.0 < this.size then |
| 69 | + l.content = next + 100; |
| 70 | + else |
| 71 | + if this.above != null then |
| 72 | + Boolean caps = this.above.caps(); |
| 73 | + if !caps then |
| 74 | + this.above.addUnit(); |
| 75 | + l.content = -1.0; |
| 76 | + else |
| 77 | + l.content = this.size; |
| 78 | + print("trap"); |
| 79 | + end |
| 80 | + else |
| 81 | + print("leak"); |
| 82 | + l.content = -1.0; |
| 83 | + end |
| 84 | + end |
| 85 | + l = l.next; |
| 86 | + end |
| 87 | + end |
| 88 | + end |
| 89 | + |
| 90 | + override GeoUnit clone() |
| 91 | + GeoUnit g = new ChalkUnit(null, null, null, null, null, null, this.size, this.mergeId, this.kerogenUnits); |
| 92 | + return g; |
| 93 | + end |
| 94 | + override Boolean caps() return False; end |
| 95 | + override Unit addUnit() this.kerogenUnits = new List<Double>(0.0, this.kerogenUnits); end |
| 96 | + override Unit printState() |
| 97 | + print("Chalk at: "); |
| 98 | + print(this.size); |
| 99 | + end |
| 100 | +end |
| 101 | + |
| 102 | +class SandstoneUnit extends GeoUnit (List<Double> kerogenUnits) |
| 103 | + models "a <http://purl.obolibrary.org/obo/bfo.owl#UFRGS:GeoCoreOntology_geological_object>; <http://purl.obolibrary.org/obo/bfo.owl#UFRGS:GeoCoreOntology_constituted_by> _:fr1. _:fr1 a domain:sandstone. "; |
| 104 | + |
| 105 | + override Unit update() |
| 106 | + List<Double> l = this.kerogenUnits; |
| 107 | + while l != null do |
| 108 | + Double next = l.content; |
| 109 | + if next >= 0 then |
| 110 | + if next + 100.0 < this.size then |
| 111 | + l.content = next + 100; |
| 112 | + else |
| 113 | + if this.above != null then |
| 114 | + Boolean caps = this.above.caps(); |
| 115 | + if !caps then |
| 116 | + this.above.addUnit(); |
| 117 | + l.content = -1.0; |
| 118 | + else |
| 119 | + l.content = this.size; |
| 120 | + print("trap"); |
| 121 | + end |
| 122 | + else |
| 123 | + print("leak"); |
| 124 | + l.content = -1.0; |
| 125 | + end |
| 126 | + end |
| 127 | + l = l.next; |
| 128 | + end |
| 129 | + end |
| 130 | + end |
| 131 | + |
| 132 | + override GeoUnit clone() |
| 133 | + GeoUnit g = new SandstoneUnit(null, null, null, null, null, null, this.size, this.mergeId, this.kerogenUnits); |
| 134 | + return g; |
| 135 | + end |
| 136 | + override Boolean caps() return False; end |
| 137 | + override Unit addUnit() this.kerogenUnits = new List<Double>(0.0, this.kerogenUnits); end |
| 138 | + override Unit printState() |
| 139 | + print("Sandstone at: "); |
| 140 | + print(this.size); |
| 141 | + end |
| 142 | +end |
| 143 | +class ShaleUnit extends GeoUnit (hidden Double temperature, hidden Boolean hasKerogenSource, hidden Int maturedUnits) |
| 144 | + models "a <http://purl.obolibrary.org/obo/bfo.owl#UFRGS:GeoReservoirOntology_sedimentary_geological_object>; obo:RO_0001015 _:fr3; <http://purl.obolibrary.org/obo/bfo.owl#UFRGS:GeoCoreOntology_constituted_by> _:fr1; obo:RO_0000086 _:fr2. _:fr1 a domain:shale. _:fr2 domain:datavalue %temperature; a domain:temperature. _:fr3 a domain:amount_of_organic_matter."; |
| 145 | + |
| 146 | + override Unit update() |
| 147 | + Double under = this.getSizeAbove(); |
| 148 | + this.temperature = 2.5 + ((under/1000) * 30); |
| 149 | + if this.maturedUnits > 0 then |
| 150 | + if this.above != null then |
| 151 | + Boolean caps = this.above.caps(); |
| 152 | + if !caps then |
| 153 | + this.above.addUnit(); |
| 154 | + this.maturedUnits = this.maturedUnits - 1; |
| 155 | + print("migrate from shale"); |
| 156 | + else |
| 157 | + print("trap in shale"); |
| 158 | + end |
| 159 | + else |
| 160 | + print("leak from shale"); |
| 161 | + this.maturedUnits = this.maturedUnits - 1; |
| 162 | + end |
| 163 | + end |
| 164 | + end |
| 165 | + override GeoUnit clone() |
| 166 | + GeoUnit g = new ShaleUnit(null, null, null, null, null, null, this.size, this.mergeId, this.temperature, this.hasKerogenSource, this.maturedUnits); |
| 167 | + return g; |
| 168 | + end |
| 169 | + Unit mature() |
| 170 | + if this.hasKerogenSource then |
| 171 | + this.maturedUnits = this.maturedUnits + 1; |
| 172 | + print(">> maturation on-going!"); |
| 173 | + Double under = this.getSizeAbove(); |
| 174 | + //print(">> depth"); |
| 175 | + //print(under); |
| 176 | + //print(">> temp"); |
| 177 | + //print(this.temperature); |
| 178 | + end |
| 179 | + end |
| 180 | + override Boolean caps() return True; end |
| 181 | + override Unit addUnit() skip; end |
| 182 | + override Unit printState() |
| 183 | + print("Shale at: "); |
| 184 | + print(this.size); |
| 185 | + end |
| 186 | +end |
| 187 | + |
| 188 | + |
| 189 | +hidden class DepositionGenerator(GeoUnit emitUnit, Double duration, Int times) |
| 190 | + GeoUnit emit() |
| 191 | + GeoUnit next = this.emitUnit.clone(); |
| 192 | + this.times = this.times - 1; |
| 193 | + return next; |
| 194 | + end |
| 195 | +end |
| 196 | + |
| 197 | + |
| 198 | +hidden class Driver(GeoUnit top, GeoUnit bottom) |
| 199 | + |
| 200 | + Unit sim(List<DepositionGenerator> actions, Double startPast, GeoUnit init, Double checkStart) |
| 201 | + print("> Starting simulation with t=-"); |
| 202 | + //print(startPast); |
| 203 | + this.top = init; |
| 204 | + this.bottom = init; |
| 205 | + Double now = -1.0 * startPast; |
| 206 | + List<DepositionGenerator> work = actions; |
| 207 | + while work != null do |
| 208 | + DepositionGenerator dg = work.content; |
| 209 | + while dg.times > 0 do |
| 210 | + GeoUnit un = dg.emit(); |
| 211 | + Boolean bb = this.top.canMerge(un); |
| 212 | + if bb then |
| 213 | + this.top.mergeWith(un); |
| 214 | + destroy(un); |
| 215 | + else |
| 216 | + this.top.above = un; |
| 217 | + this.top = un; |
| 218 | + un.below = this.top; |
| 219 | + end |
| 220 | + now = now + dg.duration; |
| 221 | + this.bottom.updateAll(); |
| 222 | + print("t:"); |
| 223 | + print(now); |
| 224 | + this.printState(this.bottom); |
| 225 | + if now > checkStart then |
| 226 | + List<ShaleUnit> fs = member("<domain:models> some (<obo:RO_0000056> some <domain:oil_window_maturation_trigger>)"); |
| 227 | + //print("reasoning finished"); |
| 228 | + while fs != null do |
| 229 | + fs.content.mature(); |
| 230 | + List<ShaleUnit> os = fs; |
| 231 | + fs = fs.next; |
| 232 | + destroy(os); |
| 233 | + end |
| 234 | + end |
| 235 | + end |
| 236 | + destroy(dg.emitUnit); |
| 237 | + destroy(dg); |
| 238 | + List<DepositionGenerator> s = work; |
| 239 | + work = work.next; |
| 240 | + destroy(s); |
| 241 | + end |
| 242 | + print("> Ending simulation with t =-"); |
| 243 | + print(now); |
| 244 | + end |
| 245 | + |
| 246 | + Unit printState(GeoObject fromBelow) |
| 247 | + if fromBelow != null then |
| 248 | + fromBelow.printState(); |
| 249 | + this.printState(fromBelow.above); |
| 250 | + end |
| 251 | + end |
| 252 | +end |
| 253 | + |
| 254 | +//the following part is the generated scenario |
| 255 | +main |
| 256 | + ShaleUnit source = new ShaleUnit(null, null, null, null, null, null, 40.0, 1, 0.0, True, 0); |
| 257 | + List<DepositionGenerator> dl = null; |
| 258 | + |
| 259 | + SandstoneUnit fill0 = new SandstoneUnit(null, null, null, null, null, null, 27.0, 2, null); |
| 260 | + DepositionGenerator fillAb0 = new DepositionGenerator(fill0, 2.0, 9); |
| 261 | + dl = new List<DepositionGenerator>(fillAb0, dl); |
| 262 | + |
| 263 | + SandstoneUnit fill1 = new SandstoneUnit(null, null, null, null, null, null, 50.0, 2, null); |
| 264 | + DepositionGenerator fillAb1 = new DepositionGenerator(fill1, 2.0, 8); |
| 265 | + dl = new List<DepositionGenerator>(fillAb1, dl); |
| 266 | + |
| 267 | + SandstoneUnit fill2 = new SandstoneUnit(null, null, null, null, null, null, 29.0, 2, null); |
| 268 | + DepositionGenerator fillAb2 = new DepositionGenerator(fill2, 2.0, 4); |
| 269 | + dl = new List<DepositionGenerator>(fillAb2, dl); |
| 270 | + |
| 271 | + SandstoneUnit fill3 = new SandstoneUnit(null, null, null, null, null, null, 27.0, 2, null); |
| 272 | + DepositionGenerator fillAb3 = new DepositionGenerator(fill3, 2.0, 6); |
| 273 | + dl = new List<DepositionGenerator>(fillAb3, dl); |
| 274 | + |
| 275 | + ChalkUnit ekofisk = new ChalkUnit(null, null, null, null, null, null, 99.0, 2, null); |
| 276 | + DepositionGenerator depEko = new DepositionGenerator(ekofisk, 2.0, 1); |
| 277 | + dl = new List<DepositionGenerator>(depEko, dl); |
| 278 | + |
| 279 | + ShaleUnit cap = new ShaleUnit(null, null, null, null, null, null, 30.0, 1, 0.0, False, 0); |
| 280 | + DepositionGenerator depCap = new DepositionGenerator(cap, 2.0, 1); |
| 281 | + dl = new List<DepositionGenerator>(depCap, dl); |
| 282 | + |
| 283 | + SandstoneUnit ab0 = new SandstoneUnit(null, null, null, null, null, null, 53.0, 2, null); |
| 284 | + DepositionGenerator depAb0 = new DepositionGenerator(ab0, 2.0, 7); |
| 285 | + dl = new List<DepositionGenerator>(depAb0, dl); |
| 286 | + |
| 287 | + SandstoneUnit ab1 = new SandstoneUnit(null, null, null, null, null, null, 88.0, 2, null); |
| 288 | + DepositionGenerator depAb1 = new DepositionGenerator(ab1, 2.0, 5); |
| 289 | + dl = new List<DepositionGenerator>(depAb1, dl); |
| 290 | + |
| 291 | + dl = dl.reverse(); |
| 292 | + Driver driver = new Driver(null,null); |
| 293 | + driver.sim(dl, 41.0, source, (-33.0)); |
| 294 | + |
| 295 | + |
| 296 | +/* |
| 297 | + has_source: True |
| 298 | +has_cap: True |
| 299 | +depth: 7206 |
| 300 | +*/ |
| 301 | +end |
0 commit comments