# Can you mix spatialdb.uniformDB and spatialdb.SimpleDB?

**URL:** <https://community.geodynamics.org/t/can-you-mix-spatialdb-uniformdb-and-spatialdb-simpledb/4155>\
**Category:** PyLith\
**Created:** [May 28, 2025, 5:28pm UTC](https://community.geodynamics.org/t/can-you-mix-spatialdb-uniformdb-and-spatialdb-simpledb/4155 "2025-05-28T17:28:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![earzabala](https://avatars.discourse-cdn.com/v4/letter/e/e274bd/32.png) [@earzabala](https://community.geodynamics.org/u/earzabala)\
**Post date:** [May 28, 2025, 5:28pm UTC](https://community.geodynamics.org/t/can-you-mix-spatialdb-uniformdb-and-spatialdb-simpledb/4155/1 "2025-05-28T17:28:11Z")

</div>

Hello developers,

I am running a 3D poroelastic simulation based off of magma-2d using PyLith 4.2.0.

Turning gravity on with:

gravity\_field = spatialdata.spatialdb.GravityField  
gravity\_field.gravity\_dir = [0.0, 0.0, -1.0]

works and including reference stresses in the db\_auxiliary\_field works too:

 ![Screenshot 2025-05-28 at 12.16.28 PM](https://canada1.discourse-cdn.com/flex036/uploads/geodynamics/original/2X/e/e7d560b29572556e8655dacc6e5902b8fa0e534f.png)

However, the reference stresses above are specified using UniformDB. I want to include them using simpleDB so that I have stresses that increase with depth according to the overburden pressure for gravitational body forces. Like the example file in subduction-3d/mat\_initial\_stress\_grav.spatialDB:

 ![Screenshot 2025-05-28 at 12.22.57 PM](https://canada1.discourse-cdn.com/flex036/uploads/geodynamics/original/2X/b/bfbb6563a976468ee3fc2e27cbbf4c09a8baa29f.png)

Can I mix spatialdb.uniformDB and spatialdb.SimpleDB ? uniformDB for the material properties and simpleDB for the references stresses? How would I update my pylithapp.cfg (attached)?  
[pylithapp.cfg](https://community.geodynamics.org/uploads/short-url/p3UJBwZ0ffjVjsh7TruVotAgwk2.cfg) (4.1 KB)

Thank you,  
Eduardo

---

<div class="post-metadata">

**Author:** ![baagaard](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/baagaard/32/615_2.png) [@baagaard](https://community.geodynamics.org/u/baagaard)\
**Post date:** [May 28, 2025, 7:37pm UTC](https://community.geodynamics.org/t/can-you-mix-spatialdb-uniformdb-and-spatialdb-simpledb/4155/2 "2025-05-28T19:37:01Z")

</div>

There are two options. The easiest option is to use a `SimpleDB` or `SimpleGridDB` and list uniform values for the cases in which there is no spatial variation. A more sophisticated approach is to use `CompositeDB` with two spatial databases, a `UniformDB` for the values that are uniform and a `SimpleDB` or `SimpleGridDB` for the values that vary spatially.

Here is the documentation for the `CompositeDB` with an example:

> **[CompositeDB — SpatialData 3.1.3 documentation](https://spatialdata.readthedocs.io/en/latest/user/components/spatialdb/CompositeDB.html)**
