There is data every hour for one week (n=168).
I would like to use this data (list) to calculate as follows.
・Calculate every hour
・Once you have completed the calculations for one day (24 hours), add them all up and calculate a1, b1, c1.
・The calculated a1, b1, c1 will be used for the next day’s calculation.

I don’t know how to substitute a1, b1, c1 calculated using the attached data into a, b, c and use it for the next day’s calculation. Could you please let me know if there is a better way?

Note that we first placed a Colibli Input component so that calculations for one week can be done with one click.

the “and calculate a1, b1, c1” is the reason why the loop exists, and is based -if I have understood correctly- on static data (168 hourly entries partitioned into lists of 24 values) and these a1, b1, c1 calculations, which should be dependant on their own previous_loop value?

keep in mind that very often a loop is not needed… but again, it all depends on how/what you are going to calculate/use a1, b1, c1 for

Let the daily production amount [g] of each block be a, b, and c.
The posted program has been truncated, but in the original program, the daily (24 hour) production amount calculated for each hour is distributed to a, b, and c using the specified distribution ratio.
a is used for hourly calculations (the value of a changes daily) and once a day, and b and c are used only once a day.

Correct me if I’m wrong, but in the gh file I received, it seems that a is only used for once a day calculations. I’m thinking of a way to use a for both hourly calculations and once a day calculations. Can anemone be used in this case?

Please let me know if you have any good ideas.
thank you.

data of all the week is inside 1 and is divided in lists of 24 elements (one day is a branch)
variable “a” has an initial value inside the Data component in A
LOOP STARTS!
first cycle ( Couter = 0 ) sends a value of 0 to Tree Branch and extracts branch {0} which is the first list of 24 hourly measurements for the first day

this list gets evaluated somehow together with the initial value of variable “a”, and generates a new variable “a” that is sent to Loop End for the next cycle:

because the next loop-cycle will have Counter = 1, then the Tree Branch will extract the data at branch {1} which is data for the second day, and will use the new_a that we have just calculated in the previous cycle with this second_day_measurements

that will generate a new_a again, that will be looped back with counter = 2, branch {2} that is the third day… and so on

how do variable_b and variable_c participate in all this?
when are they used? when do they need to be recalculated? in function of what?

Thank you for your easy-to-understand explanation.

To go into more detail, the original program is a program that calculates plant growth.
I’m sorry that I can’t show you it.

The hourly values (list) originally prepared correspond to the amount of solar radiation, and a, b, and c correspond to the dry weight of leaves, stems, and fruits, respectively. This model first calculates the amount of sugars (photosynthetic products) produced by absorbing CO2, and then distributes the photosynthetic products to leaves, stems, and fruits.

Specifically, first, convert the value of a to leaf area and calculate the amount of photosynthetic products per hour. After calculating the photosynthetic products for one day (24 hours), add them up and distribute the photosynthetic products to a, b, and c using the specified partition coefficient.
With these calculations, we are trying to estimate how much CO2 the plants have absorbed and the yield of fruit.

[calculation is triggered by pressing the button on top left, linked to Loop Start component]

A, B, C are dry weight of leaves, stems, fruits, and they have an initial value
(initial values groups are in red color)

when the loop starts, (1) we get the info about the first 24 hours of solar radiation

then we have a formula of some sort (2) that converts the value of A into “Leaf Area”

after that we use this just calculated “leaf area” together with the amount of solar radiation to get (3) the amount of photosynthetic products produced each hour for one day

then those amounts are summed up together (4) into total amount of photosynthetic products produced in one day

as last thing, photosynthetic products are distributed among leaves, stems and fruits with (5) (the current formulas for those are just silly placeholders)

the data of interest should be in (6) as daily amount of photosynthetic products received by fruits

if the distribution ratio for photosynthetic products is fixed (or proportional) then I guess including B and C in the looping is not necessary, as for each day you could calculate the amount of photosynthetic products received by C as a ratio of A

I solved the original problem, but there was a calculation I wanted to add, and that calculation caused a problem. If you don’t mind, could you give me your advice on the problem I’m currently experiencing?

I would like to create a program that takes into account the lifespan of leaves.

Set the leaf lifespan. Here, we will temporarily set the lifespan to 5 days.

When calculating on the 5th day, subtract the initial value of leaf weight from the total value.

When calculating the 6th day, subtract the weight of the leaves produced by photosynthesis on the 1st day from the total value.
-Repeat this calculation.

I made some edits to the gh file you previously created, but I can’t think of a good way to do the calculations. Could you please let me know if you have any good ideas?

if I have understood correctly, I think we need to insert two new variables in the loop

if C is the count of the iterations (starts from 0 on first day) and X is the lifespan of leaves, then:

at day 0, and each time C is a multiple of X

a (new) looped variable D stores the current weight of leaves

a (new) looped variable E stores the weight of the leaves produced by photosynthesis

both these variables get updated only when C is multiple of X, or simply C%X=0

after at least X days, each time C is a multiple of X

subtract D (last stored value of leaf weight, from X days ago) from the total leaf weight
-this calculation happens only if C>=X and C%X=0, so it doesn’t happen on start day

after at least X days, each “next day” of C being a multiple of X

subtract E (last value of weight of the leaves produced by photosynthesis, from X+1 days ago) from the total amount of photosynthesis

this calculation happens only if C>X and C%X=1, so it doesn’t happy on the day just after start

I made a diagram of the calculation image. The diagram shows the same amount of leaves increasing every day, but in reality, the amount of leaves increasing each day should be different. The black leaves in the diagram are leaves that have reached the end of their lifespan, and I would like to subtract the weight of the black leaves from the total weight of the leaves.

I think there’s a subtle misunderstanding on how the calculation is run
it looks like the amount that is calculated in A -at the moment- is actually just the “daily increment” of dry weight of leaves (equivalent to “dry weight of leaves that where created on this day”)

for instance, taking into consideration the very first iteration, C=0, the data flow is something like:

where we have an initial dry weight of leaves (1) that produces a finite amount of photosynthetic products based on sun radiation (2), based on which we calculate how much new dry leaves are produced (3)

this amount of just new leaves produced by the daily radiation (3) is then bounced back and looped (4) in such a way a new day starts, and everything is calculated from scratch

index 0 = initial dry weight of leaves, which create:
index 1 = dry weight of new-leaves-only on day 1 (generated on day 0) which create:
index 2 = dry weight of new-leaves-only on day 2 (generated on day 1) which create:
index 3… and so on

so, in order to get what you have nicely described, I think we have to turn off the Record Data feature of Anemone, and loop a populated list of all the A (one value per day)

I will work on this update tomorrow, do you follow my thought and agree with it?

Thank you for considering the calculation method. I agree with your thoughts.
If you have updated the gh file, I would appreciate it if you could share it with me.

A B C Loop-output lists carry daily production amounts, which means that if you want to know the total production in C days you need to mass addition them together