underworldcode / UWGeodynamics

Underworld Geodynamics
Other
81 stars 32 forks source link

Coupled models not working with Badlands #149

Closed bknight1 closed 4 years ago

bknight1 commented 5 years ago

Hi @rbeucher,

I've been trying to run a coupled surface model with UWGeodynamics version 2.8.4 using the docker image, but get the following error message:

Processing surface with Badlands
/usr/local/lib/python3.5/dist-packages/pint/quantity.py:1377: UnitStrippedWarning: The unit of the quantity is stripped.
  warnings.warn("The unit of the quantity is stripped.", UnitStrippedWarning)
Traceback (most recent call last):
  File "BadlandsE-WQ_06Nov19-25km_CT-2-LR.py", line 970, in <module>
    Model.run_for(Total_Time * u.megayears, checkpoint_interval=The_Checkpoint_interval*u.megayears)
  File "/usr/local/lib/python3.5/dist-packages/pint/registry_helpers.py", line 247, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/UWGeodynamics/_model.py", line 1634, in run_for
    self._update()
  File "/usr/local/lib/python3.5/dist-packages/UWGeodynamics/_model.py", line 1748, in _update
    self.surfaceProcesses.solve(dt)
  File "/usr/local/lib/python3.5/dist-packages/UWGeodynamics/surfaceProcesses.py", line 215, in solve
    self.badlands_model.run_to_time(self.time_years + dt_years)
  File "/opt/pyBadlands/pyBadlands/model.py", line 318, in run_to_time
    if self.input.erolays >= 0:
TypeError: unorderable types: NoneType() >= int()

I did see a similar error message posted a couple of months ago and was wondering if it got fixed?

Thanks

rbeucher commented 5 years ago

Hi @bknight1

Yes this is due to some changes in badlands. The Dev image should work.. I am going to build a patched image for that asap.

bknight1 commented 5 years ago

Thanks for getting back to me so quickly @rbeucher. I tried the dev branch (v2.9.0 tag:dev) but still got the same error message. UWGeo v2.7.7 (tag:badlands) seems to be working fine.

I'll close this for now and keep an eye out for the patched image.

Thanks again

bknight1 commented 4 years ago

Hi @rbeucher just a quick follow up, are the badlands models serial only or should they work in parallel too? I've been trying to use the docker image, UWGeo v2.7.7 (tag:badlands), but seems to get stuck on the surface processes when run in parallel.

rbeucher commented 4 years ago

Badlands is serial but you should be able to use UWGeodynamics in parallel. It will just use one thread for Badlands. Can you tell me a bit more about what you are doing? Is the code running in serial. Note that the badlands tag is deprecated. The default images should all have Badlands now.

bknight1 commented 4 years ago

I'm running a lithosphere-scale convergence model, 1200km by 300km, with a 30 km sticky air layer.

The model gets stuck in parallel when running the badlands solver for the surface processes. I'll update to the newest tag and see if that solves the issue.

bknight1 commented 4 years ago

@rbeucher Saw the recent update and thought I'd give it another go, but getting the following message:

AttributeErrorTraceback (most recent call last)
<ipython-input-61-45814accddda> in <module>
      5 Model.surfaceProcesses = GEO.surfaceProcesses.Badlands(airIndex=[air.index], sedimentIndex=[Sediment.index],
      6                                           XML="badlands-erosion.xml", resolution=1. * u.kilometer,
----> 7                                           checkpoint_interval=0.01 * u.megayears)
      8 
      9 #GEO.surfaceProcesses.Badlands?

/usr/local/lib/python3.5/dist-packages/UWGeodynamics/_model.py in surfaceProcesses(self, value)
    508         if value:
    509             self._surfaceProcesses.timeField = self.timeField
--> 510             self._surfaceProcesses.Model = self
    511 
    512     def set_temperatureBCs(self, left=None, right=None,

/usr/local/lib/python3.5/dist-packages/UWGeodynamics/surfaceProcesses.py in Model(self, value)
     34         self._Model = value
     35         if value:
---> 36             self._init_model()
     37 
     38     @abc.abstractmethod

/usr/local/lib/python3.5/dist-packages/UWGeodynamics/surfaceProcesses.py in _init_model(self)
    122 
    123             # Build Mesh
--> 124             self.badlands_model.build_mesh(self._demfile, verbose=False)
    125 
    126             self.badlands_model.input.outDir = self.outputDir

AttributeError: 'Model' object has no attribute 'build_mesh'
rbeucher commented 4 years ago

OK yes, there is something wrong. Let me check Badlands.

rbeucher commented 4 years ago

yeah I can see that build_mesh was renamed to _build_mesh I have fixed that. Give it a go. I haven't taken the time to test it though, let me know if it breaks.

bknight1 commented 4 years ago

Updated and managed to get to the model run, however get the following error:

Processing surface with Badlands

TypeErrorTraceback (most recent call last)
<ipython-input-60-efb9a72ce23a> in <module>
      2     Model.run_for(Total_Time * u.megayears, checkpoint_interval=The_Checkpoint_interval*u.megayears, restartStep=-1, restartDir=RestartDirectory)
      3 else:
----> 4     Model.run_for(Total_Time * u.megayears, checkpoint_interval=The_Checkpoint_interval*u.megayears)
      5 
      6 

/usr/local/lib/python3.5/dist-packages/pint/registry_helpers.py in wrapper(*args, **kwargs)
    245                     raise DimensionalityError(value, 'a quantity of',
    246                                               val_dim, dim)
--> 247             return func(*args, **kwargs)
    248         return wrapper
    249     return decorator

/usr/local/lib/python3.5/dist-packages/UWGeodynamics/_model.py in run_for(self, duration, checkpoint_interval, nstep, checkpoint_times, restart_checkpoint, dt, restartStep, restartDir, output_units)
   1632             comm.Barrier()
   1633 
-> 1634             self._update()
   1635 
   1636             self.step += 1

/usr/local/lib/python3.5/dist-packages/UWGeodynamics/_model.py in _update(self)
   1747 
   1748         if self.surfaceProcesses:
-> 1749             self.surfaceProcesses.solve(dt)
   1750 
   1751         # Update Time Field

/usr/local/lib/python3.5/dist-packages/UWGeodynamics/surfaceProcesses.py in solve(self, dt, sigma)
    213 
    214             # Run the Badlands model to the same time point
--> 215             self.badlands_model.run_to_time(self.time_years + dt_years)
    216 
    217         self.time_years += dt_years

/usr/local/lib/python3.5/dist-packages/badlands/model.py in run_to_time(self, tEnd, verbose)
    317                         if self.strata is not None:
    318                             updateMesh, regdX, regdY = self.force.load_Disp_map(self.tNow, self.FVmesh.node_coords[:, :2],
--> 319                                                                   self.inIDs, True, self.strata.xyi, self.strata.ids)
    320                         else:
    321                             updateMesh = self.force.load_Disp_map(self.tNow, self.FVmesh.node_coords[:, :2], self.inIDs)

/usr/local/lib/python3.5/dist-packages/badlands/forcing/forceSim.py in load_Disp_map(self, time, tXY, inIDs, strata, sXY, insIDs)
    543                 sdispY[insIDs] = interpolate.interpn( (self.regX, self.regY), disprY, dpsXY, method='linear')
    544 
--> 545         if self.time3d > 0. and (self.injected_disps is not None or self.Map_disp[event] != None):
    546             rate = (self.next_disp - time) / (self.T_disp[event,1] - self.T_disp[event,0])
    547             assert rate > 0

TypeError: unorderable types: NoneType() > float()
rbeucher commented 4 years ago

Yes pb with line 545. @tristan-salles I think we need an extra constraint there.

if self.time3d and self.time3d > 0 ...

rbeucher commented 4 years ago

@tristan-salles

That was in the PR I submitted...

https://github.com/badlands-model/pyBadlands_serial/pull/8/commits/b71866624333472e694403d6a3628a3acf87b9cb

rbeucher commented 4 years ago

This should be fixed in the new version of Badlands