I have tried to calculate and plot the stress ratio for 2D elements.

Here is my code.

Code: Select all

```
from PyMpc import *
from PyMpc import MpcOdbVirtualResult as vr
doc = App.postDocument()
db = doc.getDatabase(1)
# get stress at initial stage
initial_stage = 1
S22= db.getElementalResult('stress (Volumes; Components {σ22',match = MpcOdb.Contains, time = vr.stageEnd(initial_stage))
S12= db.getElementalResult('stress (Volumes; Components {σ23',match = MpcOdb.Contains, time = vr.stageEnd(initial_stage))
S22 += (S22 == 0.0)*1.0e-12
S12 += (S12 == 0.0)*1.0e-12
Sratio = S12/(S22)
Sratio.setDisplayName('Stress Ratio')
Sratio.setComponentLabels(['stress_ratio'])
db.addVirtualResult(Sratio)
```

I got the following error messages.

Code: Select all

```
Cannot add the virtual results due to the following errors:
MpcOdbElementalResultWithField: Result is NULL
MpcOdbElementalResultWithField: Result is NULL
```

Many thanks for your help.