Issue with this line
You are trying to access D as a vector, is that so?
Also you used D in the following line also
D might be scalar data (one numeric value), as per z1 statement
More: It may be typo mistake, D may be Dv, bacause you have defined Dv, but not use anywhere in the code.