# FISH function for elastic modulus increment with depth

**URL:** <https://forum.itascainternational.com/t/fish-function-for-elastic-modulus-increment-with-depth/1915>\
**Category:** FLAC\
**Tags:** fish\
**Created:** [January 25, 2025, 3:12am UTC](https://forum.itascainternational.com/t/fish-function-for-elastic-modulus-increment-with-depth/1915 "2025-01-25T03:12:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![agapanto](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@agapanto](https://forum.itascainternational.com/u/agapanto)\
**Post date:** [January 25, 2025, 3:12am UTC](https://forum.itascainternational.com/t/fish-function-for-elastic-modulus-increment-with-depth/1915/1 "2025-01-25T03:12:21Z")

</div>

Hi all,

I’d like to initialize a non linear distribution of elastic moduli in my FLAC slope model. In particular, I would like to vary the moduli according to the depth from the ground level considering a the top left-hand grid point (i.e., y(1,jgp)) as a reference point.  
I’m therefore trying to write a fish function called “linear\_mod” but I cannot understand why it’s not working. It seems that the script does not produce any variation of the modules within the group in which I would like this variation to take place.

Here is the script:

```auto
;---------------------------------------------------------------------
config creep thermal extra 5

;------------------------DOMAIN WITH UNIFORM MESH (5x5m)
; I'm generating a domain with negative coordinates because part of the slope
; is below sea level

grid 430 106
gen 0 -300 0 230 2150 230 2150 -300 
mod el

;------------TOPOGRAPHY
gen line 0 230 1330 102
gen line 1330 102 1335 65
gen line 1335 65 2150 0
gen line 0 190 1335 65
ini x 1329.7183 y 102.10892 i 267 j 81
model null region 399,90

;------------STRATIGRAPHY
group sands region 3,101 
group clays region 3,95
mod el group sands
prop den 2400 bulk = 1000 shear = 500 group sands
mod el group clays
prop den 2050 bulk = 2000 shear = 100 group clays

;----------------------------------------------------------

def linear_mod
	loop i (1,izones)
	  	loop j (1,jzones)
			if z_group(i,j) = 'clays' then 
				yc = (y(i,j)+y(i+1,j)+y(i,j+1)+y(i+1,j+1))/4.0 ; Centroid of each zone
				zc = y(1,jgp) - yc ; Depth of any zone centroid below the surface
				xc = zc * Gn * K 
				bulk_mod(i,j) = Km * xc - Kq ; Bulk modulus
				shear_mod(i,j) = Gm * xc - Gq ; Shear modulus
			endif
		endloop
	endloop
end

set Gn = 2050 K = 0.5 Km = 30 Kq = 50 Gm = 20 Gq = 40

linear_mod

```

I’m using FLAC v.8.

Can anyone tell me where I am wrong?

Thanks a lot in advance.

---

<div class="post-metadata">

**Author:** ![jwang](https://avatars.discourse-cdn.com/v4/letter/j/b782af/32.png) [@jwang](https://forum.itascainternational.com/u/jwang)\
**Post date:** [January 27, 2025, 3:16pm UTC](https://forum.itascainternational.com/t/fish-function-for-elastic-modulus-increment-with-depth/1915/2 "2025-01-27T15:16:08Z")

</div>

Try using K0=0.5 instead of K=0.5. By default K takes integer number, if a float number is assigned, it will cause truncation of the result.(for example, K=0.5 produces the result K=0)

---

<div class="post-metadata">

**Author:** ![agapanto](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@agapanto](https://forum.itascainternational.com/u/agapanto)\
**Post date:** [January 27, 2025, 5:23pm UTC](https://forum.itascainternational.com/t/fish-function-for-elastic-modulus-increment-with-depth/1915/3 "2025-01-27T17:23:29Z")

</div>

Thank you jwang!

I had already tried this way but nothing changes. Even if I assign a different name to the variable K (i.e., ‘K0’ or ‘Var’) or a different integer value (i.e., 1 or 2) I always get the same result.  
What can it depend on?

---

<div class="post-metadata">

**Author:** ![jwang](https://avatars.discourse-cdn.com/v4/letter/j/b782af/32.png) [@jwang](https://forum.itascainternational.com/u/jwang)\
**Post date:** [January 27, 2025, 5:46pm UTC](https://forum.itascainternational.com/t/fish-function-for-elastic-modulus-increment-with-depth/1915/4 "2025-01-27T17:46:13Z")

</div>

There might be some other fish variables in your code that have conflict with other FLAC command/fish names, i suggest add underscore ‘\_’ for each fish variable to avoid any conflict. See the updated code below:  
;------------------------DOMAIN WITH UNIFORM MESH (5x5m)  
; I’m generating a domain with negative coordinates because part of the slope  
; is below sea level  
config dynamic  
grid 430 106  
gen 0 -300 0 230 2150 230 2150 -300  
mod el  
;------------TOPOGRAPHY  
gen line 0 230 1330 102  
gen line 1330 102 1335 65  
gen line 1335 65 2150 0  
gen line 0 190 1335 65  
ini x 1329.7183 y 102.10892 i 267 j 81  
model null region 399,90  
;------------STRATIGRAPHY  
group sands region 3,101  
group clays region 3,95  
mod el group ‘sands’  
prop den 2400 bulk = 1000 shear = 500 group ‘sands’  
mod el group ‘clays’  
prop den 2050 bulk = 2000 shear = 100 group ‘clays’  
;----------------------------------------------------------  
def linear\_mod  
loop i (1,izones)  
loop j (1,jzones)  
if z\_group(i,j) = ‘clays’ then  
\_yc = (y(i,j)+y(i+1,j)+y(i,j+1)+y(i+1,j+1))/4.0 ; Centroid of each zone  
\_zc = 230 - \_yc ; Depth of any zone centroid below the surface  
\_xc = \_zc \* \_Gn \* \_K0  
bulk\_mod(i,j) = \_Km \* \_xc - \_Kq ; Bulk modulus  
shear\_mod(i,j) = \_Gm \* \_xc - \_Gq ; Shear modulus  
endif  
endloop  
endloop  
end  
set \_Gn = 2050 \_K0 = 0.5 \_Km = 30 \_Kq = 50 \_Gm = 20 \_Gq = 40  
linear\_mod

---

<div class="post-metadata">

**Author:** ![agapanto](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@agapanto](https://forum.itascainternational.com/u/agapanto)\
**Post date:** [January 27, 2025, 8:27pm UTC](https://forum.itascainternational.com/t/fish-function-for-elastic-modulus-increment-with-depth/1915/5 "2025-01-27T20:27:15Z")

</div>

Thank you so much jwang!!
