I am doing this to solve for pressure head (H) and velocity (V) at various location and different time step. X axis (represented by i value) is the location, Y axis (represented by j value) is the time step.
i made a mistaka, H shall vary with i value, i.e.
Hi,j = 119.3m – [(119.3m-112.5m)*(i*Δx/5000m)]
i have corrected it, but same error comes out: This array index is invalid for this array..
Attached is an example of a finite difference solution to a differential equation. You develop vectors for the parameters you are solving for, and assign guess values. (You need a vector of X (nodes along your pipe), and Vectors for H and V that specify values at each node. (starting guesses are not terribly critical, they can be constant values in all cells.) You then create a cost function (basically your "C" algorithms) that define the relationships. A solve block is used to find the values that solve the cost function. The solution then plots the vector values along the nodes.
As for "invalid indices:
A vector needs only one index, so H sub i,j has one too many indices.
By default Mathcad starts indices at 0. You may change this with the built-in variable "ORIGIN"
However, i saw the second file which you changed the original equation to Cost function. May i know if Cost carry any special meaning?
Is it possible to add in both i and j in Cost function? i and j are equally important in solving this set of equations, where i represents the point of interest and j represents the time step (the response of H and V over a period of time).
Initial values at 0 time step (j=0) shall be defined as:
whereby Velocity (V) at 0 time step (j=0) will be constant along the pipeline (i=1,2.. 5000); Pressure Head (H) will reduce proportionally from the starting point to end point (i=1,2.. 5000) at 0 time step (j=0).
Is there any way we can discuss this in a more efficient manner? via skype or some other ways?
I am really keen to learn more about Mathcad, if you're convenient to share your knowledge.
Truly appreciate if you could help. Thanks in advance!
Is it possible to add in both i and j in Cost function? i and j are equally important in solving this set of equations, where i represents the point of interest and j represents the time step (the response of H and V over a period of time).
Initial values at 0 time step (j=0) shall be defined as:
whereby Velocity (V) at 0 time step (j=0) will be constant along the pipeline (i=1,2.. 5000); Pressure Head (H) will reduce proportionally from the starting point to end point (i=1,2.. 5000) at 0 time step (j=0).
If you want to use j as a time index you need to set it up that way. You need to set up H and V as arrays (with I rows and j columns) then write your cost functions as functions of arrays H and V and indices I and j.
Excerpted from the file you couldn't open:
The Given/Find construct is a "solve block." Mathcad will (if things go well) find the values of Y that satisfy the constraints. (Go read the help for solve blocks.)
This is a challenging problem. Might be a good idea to explore some of the examples in the help files to understand better what you're trying to do.
Mathcad can also solve differential equations; you might want to explore that.