# How to generate a new field from other fields without calculator

**URL:** https://discourse.paraview.org/t/how-to-generate-a-new-field-from-other-fields-without-calculator/17205
**Category:** ParaView Support
**Created:** [September 24, 2025, 3:26pm UTC](https://discourse.paraview.org/t/how-to-generate-a-new-field-from-other-fields-without-calculator/17205 "2025-09-24T15:26:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![DavidLarry](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/71c47a/32.png) [@DavidLarry](https://discourse.paraview.org/u/DavidLarry)
#### Post date: [September 24, 2025, 3:26pm UTC](https://discourse.paraview.org/t/how-to-generate-a-new-field-from-other-fields-without-calculator/17205/1 "2025-09-24T15:26:03Z")

</div>

Dear support,

I am trying to estimate the principal stress from stress and shear stress components using matrix resolution.

This type of resolution cannot be used in a calculator ad thus I wanted to do it using pvbatch:

1. loop over all cells
2. Solve the matrix for each cell
3. Add the result to a new field
4. Visualise the new field over the whole domain

Could anyone help me, especially regarding the creation of a new field (cell based) and the filling of said field?

Thank you

PS: long live Paraview

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [September 24, 2025, 3:30pm UTC](https://discourse.paraview.org/t/how-to-generate-a-new-field-from-other-fields-without-calculator/17205/2 "2025-09-24T15:30:39Z")

</div>

> [@DavidLarry](#):
>
> This type of resolution cannot be used in a calculator ad thus I wanted to do it using pvbatch:

You want to do that using a programmable filter 🙂

> **[6. Programmable Filter — ParaView Documentation 6.0.0 documentation](https://docs.paraview.org/en/latest/ReferenceManual/pythonProgrammableFilter.html)**

---

<div class="post-metadata">

### Author: ![DavidLarry](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/71c47a/32.png) [@DavidLarry](https://discourse.paraview.org/u/DavidLarry)
#### Post date: [September 24, 2025, 4:42pm UTC](https://discourse.paraview.org/t/how-to-generate-a-new-field-from-other-fields-without-calculator/17205/3 "2025-09-24T16:42:53Z")

</div>

Hello Mathieu,

Thanks for the quick feedback, it’s a nice feature that I didn’t know about.

So I gave it a try and I can recover the data I want using the examples.

The only issue I have then is using VTKArray with numpy, due to the format of the data:

 ![image](https://discourse.paraview.org/uploads/default/original/3X/3/e/3e8d6456c7a8f4f6165d975d32aed9c5e8620f4d.png)

How can I convert it to numpy array? I tried np.array on the VTKArray but it failed.

Thank you

Below the script I tried to use

##############################################  
Code for ‘Script’

```auto
import numpy as np

input0 = inputs\[0\]

#Recover data

sigma_x = np.array(input0.CellData\[“sigma_xx”\])
sigma_y = np.array(input0.CellData\[“sigma_yy”\])
sigma_z = np.array(input0.CellData\[“sigma_zz”\])
tau_xy = np.array(input0.CellData\[“sigma_xy”\])
tau_yz = np.array(input0.CellData\[“sigma_yz”\])
tau_xz = np.array(input0.CellData\[“sigma_xz”\])

#Build the tensor

sigma_tensor = np.array(\[
\[sigma_x, tau_xy, tau_xz\],
\[tau_xy, sigma_y, tau_yz\],
\[tau_xz, tau_yz, sigma_z\]
\])

#Solve the coefficients

I1 = np.trace(sigma_tensor)
I2 = (sigma_x *sigma_y + sigma_y sigma_z + sigma_z sigma_x
- tau_xy\*\ ****2 - tau_yz** \*\*2 - tau_xz\*\*2)
I3 = np.linalg.det(sigma_tensor)

```

---

<div class="post-metadata">

### Author: ![Lucas\_Givord](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lucas_givord/32/6851_2.png) [@Lucas\_Givord](https://discourse.paraview.org/u/Lucas_Givord)
#### Post date: [September 26, 2025, 7:44am UTC](https://discourse.paraview.org/t/how-to-generate-a-new-field-from-other-fields-without-calculator/17205/4 "2025-09-26T07:44:54Z")

</div>

Note that the Yield Criteria filter could compute the principal stress (but not shear stress):

 ![image](https://discourse.paraview.org/uploads/default/original/3X/7/d/7d2548c091faf823289dffc78f33bcb3ff305c91.png)

However there is some assumption regarding the tensor itself, see : [Pb with YieldCriteria Filter](https://discourse.paraview.org/t/pb-with-yieldcriteria-filter/16083)
