# Nova Workshop2015: Insecticide

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is an extension of the Lotka-Volterra that was discussed and created in the 2015 Nova Workshop at Oberlin College.

## Contents

This model looks at the rates of predator and prey with the use of insecticides.

Error creating thumbnail: File missing

### Programming Help

See the following for help with programming in JavaScript.

It may be helpful to search for Ternary Conditional, JS Math Functions, and If-else Statements in the Mozilla Developer Network site (developer.mozilla.org).

## Prey Stock and Flow

This is the code within the Births and predation Flow for the prey Stock.

Error creating thumbnail: File missing

This uses the v(n, ta, g) function that is defined in the Programming Window in the top-left corner of Nova. This function is described below.

## Predator Stock and Flow

This is the code within the eating and death Flow for the predator Stock.

Error creating thumbnail: File missing

This uses the v(n, ta, g) function that is defined in the Programming Window in the top-left corner of Nova. This function is described below.

## The v(n,ta,g) function

The v(n, ta, g) function within the Programming Window (top-left of Nova) is used in both the prey and predator Stock and Flows.

Error creating thumbnail: File missing

Note: functions have their own environment in which the variables that they use live within. You must give a function the variables that it will use. In other words, the v() function uses the variables n, ta, and g. Thus, we need to give that function those parameters (or arguments). We pass the TIME() built-in function (Primop) as the parameter n in the Births and predation and eating and death Flows.

Also, this function uses the Ternary Conditional. Conditional statements (like the if-else statement) are extremely important concepts in computer programming for most modeling.

### Alternatives to v()

We use comments in the current Programming Window. Comments are seen as the green code between the /* */ section. Commented code does not run. It is passed over. If we commented out the first function and uncommented the current green function then we could run an alternative form of the v() function. However, as we described above, we need to pass in additional parameters to this function. The v() function uses the variables n, ta, and g within. The commented function currently only takes in n - this will throw an error (or simply not work). We need to give this function the arguments ta and g just like we do with the first version of the function.

Another approach could be to skip the use of the v() function altogether. Instead, we could put the conditional statements that v() uses within the Births and predation and eating and death Flows. This would look like this:

Error creating thumbnail: File missing

Notice that we now comment out the unused function v() in the Programming Window.

Furthermore, we could make use of variables' in the Flows. We can set the variable v in the Flows with the keyword var (variable declaration). We can pass the variable v the Ternary Conditional statement that was in the v() function.

Error creating thumbnail: File missing

## Tables and Graphs

We can set the Tables and Graphs by right-clicking and going to the Properties section for each. Drag variables to the right side of the >>> arrows that you would like to show in the Table(s) and Graph(s).

Error creating thumbnail: File missing
Error creating thumbnail: File missing