Function splitting and potential optimisation

I’m new to writing FISH functions and also new to function splitting. As an exercise, I’ve made a script (below) that updates the cohesion/friction properties of each zone, as per the Hoek-Brown curve. I’ve used this in the SUBI constitutive model, to replace the cohesion/friction inputs.

My questions:

  1. I’ve only put a splitting function as part of the call back (last line of code). Is this ideal or is there other areas where I can use splitting to speed it up further? Or is there a better/faster way entirely to do this using loops or fish define for example? Just trying to get some feedback from someone more experienced if there other other/different tricks I should look at…
  2. The code stops working and I get an error, if I try to use it without splitting in the fish-call. For example, if I just use fish-call -100 setup(zone), or fish-call -100 setup([zone]), or any combination like that, I can’t get it to work. I’m not sure why that is? I’m basically trying to see how much splitting makes a difference. Without calling the function every cycle, my model takes 14sec, with the function it is 47sec, I’m not sure how fast it is with the function, but without splitting.


zone cmodel assign softening-ubiquitous
zone initialize density 2600
zone property young 40e9 poisson 0.25
fish operator setup(zone)
    local sig31 = zone.stress.max(zone) - 0.001*zone.stress.max(zone)
    local sig32 = zone.stress.max(zone) + 0.001*zone.stress.max(zone)
    local mb = mi*math.exp((gsi-100)/(28-14*d))
    local s = math.exp((gsi-100)/(9-3*d))
    local a = 0.5 + (math.exp(-gsi/15)+(math.exp(-20/3)))/6
    local sig11 = sig31 - sigc*((mb*sig31/-sigc) + s)^a
    local sig12 = sig32 - sigc*((mb*sig32/-sigc) + s)^a
    local tanpsi = (sig11-sig12)/(sig31-sig32)
    zone.prop(zone,'friction') = (math.asin((tanpsi-1)/(tanpsi+1)))/math.degrad
    zone.prop(zone,'cohesion') = math.abs((sig11*(1-math.sin(zone.prop(zone,'friction')*math.degrad))...
model solve cycles-total 1000 fish-call -100 setup([::zone.list])