# Fish function on looping over all zones

**URL:** <https://forum.itascainternational.com/t/fish-function-on-looping-over-all-zones/1235>\
**Category:** FLAC3D\
**Tags:** fish\
**Created:** [October 31, 2023, 1:16am UTC](https://forum.itascainternational.com/t/fish-function-on-looping-over-all-zones/1235 "2023-10-31T01:16:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Milads](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@Milads](https://forum.itascainternational.com/u/Milads)\
**Post date:** [October 31, 2023, 1:16am UTC](https://forum.itascainternational.com/t/fish-function-on-looping-over-all-zones/1235/1 "2023-10-31T01:16:13Z")

</div>

What is the best way to define the below 2D fish function in FLAC 3D that loops over all zones calculates Vs based on the vertical effective stress?  
loop i (1,izones)  
loop j (1,jzones)  
if model(i,j) # 1   
$sigv = -syy(i,j) - pp(i,j)  
Vs = Vs1 \* sqrt($sigv/2116)^n  
shear\_mod(i,j) = Vs^2 \* density(i,j)  
end\_if  
end\_loop  
end\_loop

---

<div class="post-metadata">

**Author:** ![cheng](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@cheng](https://forum.itascainternational.com/u/cheng)\
**Post date:** [October 31, 2023, 7:20pm UTC](https://forum.itascainternational.com/t/fish-function-on-looping-over-all-zones/1235/2 "2023-10-31T19:20:47Z")

</div>

Something like this:

> [global Vs1 = 500]  
> [global n = 0.25]  
> fish operator input\_shear(z)  
> local pp = zone.pp(z)  
> local sigv = - zone.stress(z)-\>zz - pp  
> local Vs = Vs1 \* (sigv/2116)^n  
> zone.prop(z,“shear”) = Vs^2 \* zone.density(z)  
> end  
> [input\_shear(::zone.list)])

Please check and make necessary modification for your model.

---

<div class="post-metadata">

**Author:** ![Milads](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@Milads](https://forum.itascainternational.com/u/Milads)\
**Post date:** [November 1, 2023, 4:55am UTC](https://forum.itascainternational.com/t/fish-function-on-looping-over-all-zones/1235/3 "2023-11-01T04:55:17Z")

</div>

Thank you for your response, @cheng. The provided code worked perfectly and the shear modulus vary in z direction. I have a follow-up question: after assigning the shear modulus using the code you provided, I would like to create a function that allows me to vary the shear modulus in both the x and y directions across the model. This is to assess the differential settlement resulting from a reduction in stiffness. I would greatly appreciate any guidance on how to iterate through zones within a single layer and update the shear modulus. In FLAC2D I would probably use something like below if it works:  
loop $i (1,izones)  
loop $j (1,jzones)  
IF z\_group($i,$j) = ‘Sand’ THEN  
ex\_1 ($i,$j) = z\_prop($i,$j, ‘shear’)  
z\_prop($i,$j, ‘shear’) = ex\_1 ($i,$j) \* (linear reduction function!)  
end\_if  
end\_loop  
end\_loop

---

<div class="post-metadata">

**Author:** ![cheng](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@cheng](https://forum.itascainternational.com/u/cheng)\
**Post date:** [November 1, 2023, 3:01pm UTC](https://forum.itascainternational.com/t/fish-function-on-looping-over-all-zones/1235/4 "2023-11-01T15:01:27Z")

</div>

Something like:

fish operator adj\_shear(z)  
if zone.isgroup(z,“Sand”)  
zone.prop(z,“shear”) \*= 0.5  
endif  
end  
[adj\_shear(::zone.list)])
