Sub Project_2(ByVal VecType, m, n, m1, n1 As Integer) ' Derivative pack ' Updated: 3/09/24 ' Created by: A. Becerra (21/08/24) ' Modified by: _________________ ' This is the module to calculate partial differential operators (DO). ' Steps to embed the code to ScienSolar: ' Note 1: The number 2 in the name of this function must match the one in the list of the CONFIG sheet for this project. Only the number 2 is allowed for this module ' Note 2: This code will be integrated into the main code to automate the download of the module. ' Step 1. Go to the CONFIG sheet and in E34 and F34 add a short name in English and Spanish. Set C33=1 and C34=2. Copy the formula from cell B35 to B34. ' Step 2. Make sure that the list of projects in CONFIG sheet has the correct ascending numbering. ' Step 4. Open the VBA editor (Alt + F11 in Windows or Fn + Option + F11 in macOS). To avoid mistakes, make sure you only have one workbook open. ' Step 5. On the left, in the project explorer, add a new module. ' Step 6. Select all the code in this file, copy and paste it in the new module. ' Step 7. To load the project and to check it in a new sheet, click the New Sheet button, then select the project 2 (DO) from the list and click the +Vector button. ' Step 8. Click any XYZ button to get the project in the coordinate system. Enjoy it! ' Step 9. To see examples of applying differential operators, download and install project No. 33: Examples with differential operators. ' Visit www.sciensolar.com for news and updates of ScienSolar. 'Segement DO-1. Define the button dimension pattern Dim PatronW As Double Dim PatronH As Double Cells(m + 1, n).Select PatronW = ActiveSheet.Cells(1, 1).Width PatronH = ActiveSheet.Cells(1, 2).Height PatronT = ActiveSheet.Cells(m + 5, n + 3).Top 'Segement DO-2. Enter dropdown list ActiveSheet.DropDowns.Add(PatronW * (n + 2), PatronT, PatronW * 2, 15).Select With Selection .name = "ListDerivate" .LinkedCell = Cells(m + 5, n + 3).Address .DropDownLines = 11 .Display3DShading = True .AddItem "" 'value 1 .AddItem "d/dt (scalar U)" ' value 2 .AddItem "d/dt (vector A)" ' value 3 .AddItem "Grad (scalar U)" ' value 4 .AddItem "Div (vector A)" ' value 5 .AddItem "Rot (vector A)" ' value 6 .AddItem "Laplacian (vector A)" ' value 7 .AddItem "Laplacian (scalar U)" ' value 8 .AddItem "(A grad) B <- vect A, B " ' value 9 .AddItem "(A B) <- vect A, B" ' value 10 .AddItem "[A x B] <- vect A, B" ' value 11 .Placement = xlMove 'fix dimensions '.Selected = 1 End With 'Segement DO-3. Put the Calculate button ActiveSheet.Buttons.Add(PatronW * (n + 2), PatronT + PatronH * 5.7, PatronW * 2, PatronH).Select ' agrega el bot‹n de gr_fica Selection.name = "Deriv_" & "Row" & Cells(m, n).Row & "Col" & Cells(m, n).Column Selection.Characters.Text = "Calculate DO" Selection.OnAction = "Derivative" Selection.Placement = xlMove 'Segement DO-4. Put the Mix operator button. ActiveSheet.Buttons.Add(PatronW * (n + 2), PatronT - PatronH, PatronW * 2, PatronH).Select Selection.name = "N_Deriv_" & "Row" & Cells(m, n).Row & "Col" & Cells(m, n).Column Selection.Characters.Text = "Go To Mix D.O." Selection.OnAction = "n_derivative" Selection.Placement = xlMove 'Segement DO-5. Put Info button ActiveSheet.Buttons.Add(PatronW * (n + 4), PatronT - PatronH, PatronW / 2, PatronH).Select Selection.name = "DO_" & "Row" & Cells(m, n).Row & "Col" & Cells(m, n).Column Selection.Characters.Text = "Info" Selection.OnAction = "PutEq" Selection.Placement = xlMove ' Segement DO-6. Default values If m > 3 Then Cells(m + 7, n + 3).Value = Cells(m - 6, n - 1).Value Else Cells(m + 7, n + 3).Value = 2 End If Cells(m + 3, n + 0).FormulaR1C1 = "=IF(R[2]C[3]="""",""A"",IF(R[2]C[3]=4,""grad U"",IF(R[2]C[3]=5,""div A"",IF(R[2]C[3]=6,""rot A"",IF(R[2]C[3]=7,""Lap A"",IF(R[2]C[3]=8,""Lap U"",IF(R[2]C[3]=2,""dU/dt"",""dA/dt"")))))))" Cells(m + 4, n + -1).FormulaR1C1 = "1" Cells(m + 4, n + 0).FormulaR1C1 = "183" Cells(m + 4, n + 2).FormulaR1C1 = "<-- Field view: insert s, o, c for different coordinate system views, or clean to exit field view. " If Cells(m + 4, n + 5).Value = "" Then Cells(m + 4, n + 5).FormulaR1C1 = "/////////////" If Cells(m + 11, n + 5).Value = "" Then Cells(m + 11, n + 5).FormulaR1C1 = "/////////////" Cells(m + 11, n + 2).FormulaR1C1 = "/////////////" Cells(m + 10, n + 4).FormulaR1C1 = "" Cells(m + 5, n + 2).FormulaR1C1 = " Operator:" Cells(m + 6, n + 2).FormulaR1C1 = " Delta =" Cells(m + 6, n + 3).FormulaR1C1 = "0.01" Cells(m + 7, n - 1).FormulaR1C1 = "=R[1]C" Cells(m + 7, n).FormulaR1C1 = "=R[1]C" Cells(m + 7, n + 1).FormulaR1C1 = "=R[1]C" Cells(m + 7, n + 2).FormulaR1C1 = "=IF(OR(R[-2]C[1]=2,OR(R[-2]C[1]=4,R[-2]C[1]=8)),"" U(x,y,z,t) ="",IF(OR(R[-2]C[1]=9,OR(R[-2]C[1]=10,R[-2]C[1]=11)),""Vec No. B=, A="","" Vector No. =""))" Cells(m + 8, n + -1).FormulaR1C1 = "5" Cells(m + 8, n + 0).FormulaR1C1 = "5" Cells(m + 8, n + 1).FormulaR1C1 = "0" Cells(m + 8, n + 2).FormulaR1C1 = "< -- (x,y,z)" Cells(m + 10, n - 1).FormulaR1C1 = "1" Cells(m + 10, n).FormulaR1C1 = "0" Cells(m + 10, n + 1).FormulaR1C1 = "1" Cells(m + 11, n + -1).FormulaR1C1 = "3" Cells(m + 11, n + 0).FormulaR1C1 = "0" Cells(m + 11, n + 1).FormulaR1C1 = "1" Cells(m + 3, n + 1).Interior.Color = "16777075" Cells(m + 4, n - 1).Value = 1 Cells(m1 + 2, n1 - 1).Value = 1 Columns("A:C").ColumnWidth = 10 Cells(m + 7, n + 3).Select End Sub Sub n_derivative() ' A. Becerra ' This procedure allows to mix operators (i.e. grad(div A), rot(rot( rot A))), etc ) 'Segment n_derivative-01. Define variables n = CDbl(Mid(ActiveSheet.Buttons(Application.Caller).name, InStr(1, ActiveSheet.Buttons(Application.Caller).name, "Col", 1) + 3, 1)) m = CDbl(Mid(ActiveSheet.Buttons(Application.Caller).name, InStr(1, ActiveSheet.Buttons(Application.Caller).name, "Row", 1) + 3, _ InStr(1, ActiveSheet.Buttons(Application.Caller).name, "Col") - InStr(1, ActiveSheet.Buttons(Application.Caller).name, "Row") - 3)) Dim Pref ' Message to the user Dim VecN As Integer ' Field entered by the user to apply the operator Dim VecNB As Integer ' Field entered by the user to apply the operator Dim ThisOp As Integer ' The vector number of the actual module of Dif operators (DO). Dim NFun As Integer ' The list number of the selected operator Dim TFun As String ' The type of field to which the operator will be applied (scalar or vector field) Dim DOType As String ' The type of operation: Mix is when various operators apply, Single when only one operator acts on a field. NFun = Cells(m + 5, n + 3).Value ThisOp = Cells(m + 3, n - 1).Value Select Case NFun Case 2, 4, 8 TFun = "FScalar" Case 3, 5, 6, 7, 9, 10, 11 TFun = "FVector" Case Else TFun = "Indefinite" End Select If m = 3 And Cells(m + 12, n - 1).Value = "" Then Cells(m + 5, n + 3).Value = 2 'Segment n_derivative-02. Change the parameters of the module depending on user actions. On Error Resume Next If Cells(m + 7, n + 2).FormulaR1C1 = "=IF(OR(R[-2]C[1]=2,OR(R[-2]C[1]=4,R[-2]C[1]=8)),"" U(x,y,z,t) ="",IF(OR(R[-2]C[1]=9,OR(R[-2]C[1]=10,R[-2]C[1]=11)),""Vec No. B=, A="","" Vector No. =""))" Then Cells(m + 5, n + 4).Formula = Cells(m + 7, n + 3).Application.ConvertFormula(Cells(m + 7, n + 3).Formula, xlA1, xlA1, 1) Cells(m + 7, n + 2).Value = "--" Cells(m + 8, n + 4).Value = "" If NFun > 8 Then VecN = Cells(m + 7, n + 4).Value VecNB = Cells(m + 7, n + 3).Value Else Cells(m + 7, n + 3).Value = "1st. DO:" VecN = Cells(m + 7, n + 4).Value End If ActiveSheet.Buttons(Application.Caller).Characters.Text = "Go To Single D.O." Cells(m + 7, n + 4).Select DOType = "Mix" Else Cells(m + 7, n + 2).FormulaR1C1 = "=IF(OR(R[-2]C[1]=2,OR(R[-2]C[1]=4,R[-2]C[1]=8)),"" U(x,y,z,t) ="",IF(OR(R[-2]C[1]=9,OR(R[-2]C[1]=10,R[-2]C[1]=11)),""Vec No. B=, A="","" Vector No. =""))" Cells(m + 7, n + 3).Value = Cells(m + 5, n + 4).Application.ConvertFormula(Cells(m + 5, n + 4).Formula, xlA1, xlA1, 1) If NFun > 8 Then VecN = Cells(m + 7, n + 4).Value VecNB = Cells(m + 7, n + 3).Value Else VecN = Cells(m + 7, n + 3).Value End If Cells(m + 7, n + 3).Select DOType = "Single" ActiveSheet.Buttons(Application.Caller).Characters.Text = "Go To Mix D.O." End If 'Segment n_derivative-03. Choose the optimal message to help the user manage the module of Dif Operators. Pref = " Insert the number of the other function into the selected cell." Select Case True Case (ThisOp = VecN) Pref = "Indicate the number of a vector function other than this operator." Case (ThisOp = VecNB) Pref = "Indicate the number of a vector function other than this operator." Case (NFun = 2 And DOType = "Mix") If Cells(VecN * 9 + 2, n + 3).Value = "" Then Pref = "Insert the number of a correct scalar function into the selected cell!" Else Pref = "Result: d/dt(" & Cells(VecN * 9 - 3, n).Value & ")" & " - OK! Press the button below." End If Case (NFun = 2 And DOType = "Single") Pref = "Result: dU/dt, insert U(x,y,z) in " & Cells(m + 7, n + 3).Address(0, 0) & " and press the button below." Case (NFun = 3 And DOType = "Mix") If Cells(VecN * 9 + 2, n + 3).Value <> "" Then Pref = "The result of the first operator must be a vector!" Else Pref = "Result: d/dt(" & Cells(VecN * 9 - 3, n).Value & ")" & " - OK! Press the button below." End If Case (NFun = 3 And DOType = "Single") If IsNumeric(Cells(m + 7, n + 3).Value) Then Pref = "Result: d/dt (" & Cells(VecN * 9 - 3, n).Value & ")" & " and press the button below." Else Pref = "Insert in " & Cells(m + 7, n + 3).Address(0, 0) & " the number of the vector function!" End If Case (NFun = 4 And DOType = "Mix") If Cells(VecN * 9 + 2, n + 3).Value = "" Then Pref = "The result of the first operator must be a scalar!" Else Pref = "Result: Grad(" & Cells(VecN * 9 - 3, n).Value & ")" & " and press the button below." End If Case (NFun = 4 And DOType = "Single") Pref = "Result: Grad U, insert U(x,y,z) in " & Cells(m + 7, n + 3).Address(0, 0) & " - OK! Press the button below." Case (NFun = 5 And DOType = "Mix") If Cells(VecN * 9 + 2, n + 3).Value <> "" Then Pref = "The result of the first operator must be a vector!" Else Pref = "Result: Div(" & Cells(VecN * 9 - 3, n).Value & ")" & " and press the button below." End If Case (NFun = 5 And DOType = "Single") If Cells(m + 7, n + 3).Value <> "" Then Pref = "Result: Div(" & Cells(VecN * 9 - 3, n).Value & ")" & " and press the button below." Else Pref = "Insert in " & Cells(m + 7, n + 3).Value & " the number of the vector!" End If Case (NFun = 6) If Cells(VecN * 9 + 2, n + 3).Value <> "" Then Pref = "The result of the first operator must be a vector!" Else Pref = "Result: Rot(" & Cells(VecN * 9 - 3, n).Value & ")" & " and press the button below." End If Case (NFun = 7) If Cells(VecN * 9 + 2, n + 3).Value <> "" Then Pref = "The result of the first operator must be a vector!" Else Pref = "Result: Lap(" & Cells(VecN * 9 - 3, n).Value & ")" & " and press the button below." End If Case (NFun = 8 And DOType = "Mix") If Cells(VecN * 9 + 2, n + 3).Value = "" Then Pref = "The result of the first operator must be a scalar!" Else Pref = "Result: Lap(" & Cells(VecN * 9 - 3, n).Value & ")" End If Case (NFun = 8 And DOType = "Single") Pref = "Result: Lap U, insert U(x,y,z) in " & Cells(m + 7, n + 3).Address(0, 0) Case (NFun = 9) If Cells(VecN * 9 + 2, n + 3).Value <> "" Or Cells(VecNB * 9 + 2, n + 3).Value <> "" Then Pref = "Both " & Cells(VecN * 9 - 3, n).Value & " and " & Cells(VecNB * 9 - 3, n).Value & " must be vectors!" Else Pref = "Result: (" & Cells(VecN * 9 - 3, n).Value & " grad)(" & Cells(VecNB * 9 - 3, n).Value & ")" & " and press the button below." End If Case (NFun = 10) If Cells(VecN * 9 + 2, n + 3).Value <> "" Or Cells(VecNB * 9 + 2, n + 3).Value <> "" Then Pref = "Both " & Cells(VecN * 9 - 3, n).Value & " and " & Cells(VecNB * 9 - 3, n).Value & " must be vectors!" Else Pref = "Result: (" & Cells(VecN * 9 - 3, n).Value & " " & Cells(VecNB * 9 - 3, n).Value & ")" & " and press the button below." End If Case (NFun = 11) If Cells(VecN * 9 + 2, n + 3).Value <> "" Or Cells(VecNB * 9 + 2, n + 3).Value <> "" Then Pref = "Both " & Cells(VecN * 9 - 3, n).Value & " and " & Cells(VecNB * 9 - 3, n).Value & " must be vectors!" Else Pref = "Result: (" & Cells(VecN * 9 - 3, n).Value & " x " & Cells(VecNB * 9 - 3, n).Value & ")" & " and press the button below." End If Case Else Pref = " Select an operator!" Cells(m + 7, n + 2).FormulaR1C1 = "=IF(OR(R[-2]C[1]=2,OR(R[-2]C[1]=4,R[-2]C[1]=8)),"" U(x,y,z,t) ="",IF(OR(R[-2]C[1]=9,OR(R[-2]C[1]=10,R[-2]C[1]=11)),""Vec No. B=, A="","" Vector No. =""))" End Select Cells(m + 9, n + 2).Value = Pref End Sub Sub Derivative() ' Procedure to calculate the partial differential operators of the list 'Segment Derivative-01. Define variables Dim n As Integer Dim m As Integer Dim EqPlus As Variant Dim Eq As Variant Dim EqDelta As Variant Dim VecN As Integer Dim VecA As Integer Dim VecName As Variant Dim Eqx As Variant Dim Eqy As Variant Dim Eqz As Variant Dim Bx As Variant Dim By As Variant Dim Bz As Variant Dim Ax As Variant Dim Ay As Variant Dim Az As Variant Dim funName As String Dim funName2 As String n = Mid(ActiveSheet.Buttons(Application.Caller).name, InStr(1, ActiveSheet.Buttons(Application.Caller).name, "Col", 1) + 3, 1) m = Mid(ActiveSheet.Buttons(Application.Caller).name, InStr(1, ActiveSheet.Buttons(Application.Caller).name, "Row", 1) + 3, _ InStr(1, ActiveSheet.Buttons(Application.Caller).name, "Col") - InStr(1, ActiveSheet.Buttons(Application.Caller).name, "Row") - 3) If n <> 2 Then MsgBox "The operation was not performed because the control panel is not in its original position." Else On Error Resume Next 'Segment Derivative-02. dU/dt//////////////////////////////////////////////////////////////////////// If Cells(m + 5, n + 3).Value = 2 Then ' dU/dt Eq = Cells(m + 7, n + 3).Formula EqDelta = "$E$" & m + 6 funName = " dU/dt" funName2 = " dU/dt =" ' Mix operators: '---------------------------------------------- If Cells(m + 7, n + 3).Value = "1st. DO:" Then If Cells(m + 7, n + 4).Value < 1 Then Cells(m + 7, n + 4).Value = Cells(m + 3, n - 1).Value + 1 VecN = Cells(m + 7, n + 4).Value If Cells(VecN * 9 + 2, n + 3).Value = "" Then MsgBox "You should first compute the first differential operator." GoTo out End If Eq = Cells(VecN * 9 + 2, n + 3).Formula Eq = Replace(Eq, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) If Cells(VecN * 9 - 1, n + 3).Value = "" Then Cells(VecN * 9 - 1, n + 3).Value = Cells(m + 5, n + 3).Value End If If Cells(VecN * 9 - 1, n + 3).Value = 2 Then funName = "d/dt (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "d/dt (" & Cells(VecN * 9 - 3, n).Value & ")=" End If If Cells(VecN * 9 - 1, n + 3).Value = 3 Then MsgBox "To calculate the derivative of a vector select d/dt (Vector A) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 4 Then MsgBox "To calculate the derivative of a vector select d/dt (Vector A) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 5 Then funName = "d/dt (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "d/dt (" & Cells(VecN * 9 - 3, n).Value & ")=" End If If Cells(VecN * 9 - 1, n + 3).Value = 6 Then MsgBox "To calculate the derivative of a vector select d/dt (Vector A) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 7 Then MsgBox "To calculate the derivative of a vector select d/dt (Vector A) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 8 Then funName = "d/dt (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "d/dt (" & Cells(VecN * 9 - 3, n).Value & ")=" End If Else Cells(m + 7, n + 3) = Cells(m + 7, n + 3).Application.ConvertFormula(Cells(m + 7, n + 3).Formula, xlA1, xlA1, 1) End If '------------------------------------------------------------------- 'End of mix operators If Left(Eq, 1) = "=" Then 'do nothing Else Eq = "=" & Eq End If 'dU/dt EqPlus = Replace(Eq, "$I$" & 5, "($I$" & 5 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) EqPlus = Replace(EqPlus, EqPlus, "=(" & Mid(EqPlus, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) Cells(m + 8, n + 3).Value = EqPlus Cells(m + 8, n + 4).Value = "(Scalar func.)" Cells(m + 3, n).FormulaR1C1 = funName Cells(m + 8, n + 2).Value = funName2 Cells(m + 9, n - 1).FormulaR1C1 = "=R[-1]C[4]" Cells(m + 9, n).FormulaR1C1 = "=R[-1]C[3]" Cells(m + 9, n + 1).FormulaR1C1 = "=R[-1]C[2]" Cells(m + 6, n - 1).Value = "" Cells(m + 6, n).Value = "" Cells(m + 6, n + 1).Value = "" Cells(m + 9, n + 2).Value = "" Cells(m + 11, n - 1).Value = 6 Cells(m + 4, n).Value = 146 ActiveSheet.Buttons(Application.Caller).Text = "Re-calculate DO" End If 'Segment Derivative-03. dA/dt //////////////////////////////////////////////////////////////////////// If Cells(m + 5, n + 3).Value = 3 Then ' dA/dt If IsNumeric(Cells(m + 7, n + 3).Value) Then VecN = Cells(m + 7, n + 3).Value If Cells(VecN * 9, n + 2).Value = "Delta =" Then Call n_derivative End If Else VecN = Cells(m + 7, n + 4).Value End If EqDelta = "$E$" & m + 6 ' Mix operators: '---------------------------------------------- If Cells(m + 7, n + 3).Value = "1st. DO:" Then VecN = Cells(m + 7, n + 4).Value If Cells(VecN * 9 - 1, n + 3).Value = 2 Then MsgBox "To calculate the derivative of a scalar function select d/dt (scalar U) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 3 Then funName = "d/dt (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "<-- d/dt (" & Cells(VecN * 9 - 3, n).Value & ")" End If If Cells(VecN * 9 - 1, n + 3).Value = 4 Then funName = "d/dt (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "<-- d/dt (" & Cells(VecN * 9 - 3, n).Value & ")" End If If Cells(VecN * 9 - 1, n + 3).Value = 5 Then MsgBox "To calculate the derivative of a scalar function select d/dt (scalar U) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 6 Then funName = "d/dt (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "<-- d/dt (" & Cells(VecN * 9 - 3, n).Value & ")" End If If Cells(VecN * 9 - 1, n + 3).Value = 7 Then funName = "d/dt (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "<-- d/dt (" & Cells(VecN * 9 - 3, n).Value & ")" End If If Cells(VecN * 9 - 1, n + 3).Value = 8 Then MsgBox "To calculate the derivative of a scalar function select d/dt (scalar U) ." GoTo out End If Else VecN = Cells(m + 7, n + 3).Value funName = "d/dt(" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "< -- d/dt(" & Cells(VecN * 9 - 3, n).Value & ")" End If '------------------------------------------------------------------- 'End of mix operators 'Verify if the target function is a vector function If Cells(VecN * 9 - 2, n).Value <> 183 Then MsgBox "The field function to operate on is not a vector. Change the number of the target function in the selected cell. It must correspond to a vector function." Cells(m + 7, n + 3).Select GoTo out End If ' Calculate the partial derivative of the components respecto to the time 'dAx/dt Cells(VecN * 9 + 3, n - 1) = Cells(VecN * 9 + 3, n - 1).Application.ConvertFormula(Cells(VecN * 9 + 3, n - 1).Formula, xlA1, xlA1, 1) ' convert A to $A$, etc Eq = Cells(VecN * 9 + 3, n - 1).Formula If Left(Eq, 1) = "=" Then 'do nothing Else Eq = "=" & Eq End If Eq = Replace(Eq, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) Eqx = Replace(Eq, "$I$" & 5, "($I$" & 5 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqx = Replace(Eqx, Eqx, "(" & Mid(Eqx, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) 'dAy/dt Cells(VecN * 9 + 3, n) = Cells(VecN * 9 + 3, n).Application.ConvertFormula(Cells(VecN * 9 + 3, n).Formula, xlA1, xlA1, 1) Eq = Cells(VecN * 9 + 3, n).Formula If Left(Eq, 1) = "=" Then 'do nothing Else Eq = "=" & Eq End If Eq = Replace(Eq, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) Eqy = Replace(Eq, "$I$" & 5, "($I$" & 5 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqy = Replace(Eqy, Eqy, "(" & Mid(Eqy, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) 'dAz/dt Cells(VecN * 9 + 3, n + 1) = Cells(VecN * 9 + 3, n + 1).Application.ConvertFormula(Cells(VecN * 9 + 3, n + 1).Formula, xlA1, xlA1, 1) Eq = Cells(VecN * 9 + 3, n + 1).Formula If Left(Eq, 1) = "=" Then 'do nothing Else Eq = "=" & Eq End If Eq = Replace(Eq, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) Eqz = Replace(Eq, "$I$" & 5, "($I$" & 5 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqz = Replace(Eqz, Eqz, "(" & Mid(Eqz, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) 'Put the result of the components of the vector Cells(m + 9, n - 1).Value = "=" & Eqx Cells(m + 9, n).Value = "=" & Eqy Cells(m + 9, n + 1).Value = "=" & Eqz Cells(m + 8, n + 2).Value = "" Cells(m + 8, n + 4).Value = "(Vector func.)" Cells(m + 3, n).FormulaR1C1 = funName 'Format Cells(m + 8, n + 3).Value = "" Cells(m + 6, n - 1).Value = "" Cells(m + 6, n).Value = "" Cells(m + 6, n + 1).Value = "" Cells(m + 9, n + 2).Value = funName2 Cells(m + 11, n - 1).Value = 3 Cells(m + 4, n).Value = 183 ActiveSheet.Buttons(Application.Caller).Text = "Re-calculate DO" End If 'Segment Derivative-04. GRAD U//////////////////////////////////////////////////////////////////////// If Cells(m + 5, n + 3).Value = 4 Then ' grad U Eq = Cells(m + 7, n + 3).Formula ' Mix operators '------------------------------------------------------------------- If Cells(m + 7, n + 3).Value = "1st. DO:" Then VecN = Cells(m + 7, n + 4).Value If Cells(VecN * 9 + 2, n + 3).Value = "" Then MsgBox "You should first compute the first differential operator." GoTo out End If Eq = Cells(VecN * 9 + 2, n + 3).Formula Eq = Replace(Eq, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) 'Verify the target operator If Cells(VecN * 9 - 1, n + 3).Value = "" Then Cells(VecN * 9 - 1, n + 3).Value = Cells(m + 5, n + 3).Value End If If Cells(VecN * 9 - 1, n + 3).Value = 2 Then funName = "grad (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = " <-- grad (" & Cells(VecN * 9 - 3, n).Value & ")" End If If Cells(VecN * 9 - 1, n + 3).Value = 3 Then MsgBox "To calculate the derivative of a vector function select div (vector A) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 4 Then MsgBox "To calculate the derivative of a vector function select div (vector A) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 5 Then funName = "grad (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = " <-- grad (" & Cells(VecN * 9 - 3, n).Value & ")" End If If Cells(VecN * 9 - 1, n + 3).Value = 6 Then MsgBox "To calculate the derivative of a vector function select div (vector A) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 7 Then MsgBox "To calculate the derivative of a vector function select div (vector A) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value > 7 Then funName = "grad (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = " <-- grad (" & Cells(VecN * 9 - 3, n).Value & ")" End If Else Cells(m + 7, n + 3) = Cells(m + 7, n + 3).Application.ConvertFormula(Cells(m + 7, n + 3).Formula, xlA1, xlA1, 1) funName = "grad U" funName2 = "< -- grad U (x,y,z)" End If '------------------------------------------------------------------- 'End of mix operators 'Calculate the components of Grad U If Left(Eq, 1) = "=" Then 'do nothing Else Eq = "=" & Eq End If EqDelta = "$E$" & m + 6 'dU/dx EqPlus = Replace(Eq, "$A$" & m + 8, "($A$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) EqPlus = Replace(EqPlus, EqPlus, "=(" & Mid(EqPlus, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) Cells(m + 9, n - 1).Value = EqPlus 'dU/dy EqPlus = Replace(Eq, "$B$" & m + 8, "($B$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) EqPlus = Replace(EqPlus, EqPlus, "=(" & Mid(EqPlus, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) Cells(m + 9, n).Value = EqPlus 'dU/dz EqPlus = Replace(Eq, "$C$" & m + 8, "($C$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) EqPlus = Replace(EqPlus, EqPlus, "=(" & Mid(EqPlus, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) Cells(m + 9, n + 1).Value = EqPlus Cells(m + 8, n + 4).Value = "(Vector func.)" 'Format Cells(m + 3, n).FormulaR1C1 = funName Cells(m + 8, n + 3).Value = "" Cells(m + 9, n + 2).Value = funName2 Cells(m + 8, n + 2).Value = "" Cells(m + 11, n - 1).Value = 3 Cells(m + 4, n).Value = 183 ActiveSheet.Buttons(Application.Caller).Text = "Re-calculate DO" End If 'Segment Derivative-05. DIV A//////////////////////////////////////////////////////////////////////// If Cells(m + 5, n + 3).Value = 5 Then ' div A EqDelta = "$E$" & m + 6 ' Mix operators: '------------------------------------------------------------------- If Cells(m + 7, n + 3).Value = "1st. DO:" Then VecN = Cells(m + 7, n + 4).Value 'Verify the target operator If Cells(VecN * 9 - 1, n + 3).Value = 2 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 3 Then funName = " div (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = " div (" & Cells(VecN * 9 - 3, n).Value & ") =" End If If Cells(VecN * 9 - 1, n + 3).Value = 4 Then funName = " (" & ChrW(8711) & ChrW(8729) & ChrW(8711) & ") " & Mid(Cells(VecN * 9 - 3, n).Value, 8, 1) funName2 = " (" & ChrW(8711) & ChrW(8729) & ChrW(8711) & ") " & Mid(Cells(VecN * 9 - 3, n).Value, 8, 1) & " =" End If If Cells(VecN * 9 - 1, n + 3).Value = 5 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 6 Then funName = " div (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "div (" & Cells(VecN * 9 - 3, n).Value & ") =" End If If Cells(VecN * 9 - 1, n + 3).Value = 7 Then funName = " div (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "div (" & Cells(VecN * 9 - 3, n).Value & ") =" End If If Cells(VecN * 9 - 1, n + 3).Value = 8 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If Else VecN = Cells(m + 7, n + 3).Value funName = " div (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = " div (" & Cells(VecN * 9 - 3, n).Value & ") =" End If '------------------------------------------------------------------- 'End of mix operators 'verify if the target operator is a vector function If Cells(VecN * 9 - 2, n).Value <> 183 Then MsgBox "The field function to operate on is not vector function. Change the number of the target function in the selected cell. It must correspond to a vector function." Cells(m + 7, n + 3).Select GoTo out End If 'Calculate the components 'dVx/dx Cells(VecN * 9 + 3, n - 1) = Cells(VecN * 9 + 3, n - 1).Application.ConvertFormula(Cells(VecN * 9 + 3, n - 1).Formula, xlA1, xlA1, 1) Eq = Cells(VecN * 9 + 3, n - 1).Formula If Left(Eq, 1) = "=" Then 'do nothing Else Eq = "=" & Eq End If Eq = Replace(Eq, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) Eqx = Replace(Eq, "$A$" & m + 8, "($A$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqx = Replace(Eqx, Eqx, "(" & Mid(Eqx, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) 'dVy/dy Cells(VecN * 9 + 3, n) = Cells(VecN * 9 + 3, n).Application.ConvertFormula(Cells(VecN * 9 + 3, n).Formula, xlA1, xlA1, 1) Eq = Cells(VecN * 9 + 3, n).Formula If Left(Eq, 1) = "=" Then 'do nothing Else Eq = "=" & Eq End If Eq = Replace(Eq, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) Eqy = Replace(Eq, "$B$" & m + 8, "($B$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqy = Replace(Eqy, Eqy, "(" & Mid(Eqy, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) 'dVz/dz Cells(VecN * 9 + 3, n + 1) = Cells(VecN * 9 + 3, n + 1).Application.ConvertFormula(Cells(VecN * 9 + 3, n + 1).Formula, xlA1, xlA1, 1) Eq = Cells(VecN * 9 + 3, n + 1).Formula If Left(Eq, 1) = "=" Then 'do nothing Else Eq = "=" & Eq End If Eq = Replace(Eq, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) Eqz = Replace(Eq, "$C$" & m + 8, "($C$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqz = Replace(Eqz, Eqz, "(" & Mid(Eqz, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) 'Put the result Cells(m + 8, n + 3).Value = "=" & Eqx & "+" & Eqy & "+" & Eqz Cells(m + 8, n + 4).Value = "(Scalar func.)" Cells(m + 8, n + 2).Value = funName2 Cells(m + 3, n).Value = funName 'Format Cells(m + 9, n - 1).FormulaR1C1 = "=R[-1]C[4]" Cells(m + 9, n).FormulaR1C1 = "=R[-1]C[3]" Cells(m + 9, n + 1).FormulaR1C1 = "=R[-1]C[2]" Cells(m + 9, n + 2).Value = "" Cells(m + 11, n - 1).Value = 6 Cells(m + 4, n).Value = 146 ActiveSheet.Buttons(Application.Caller).Text = "Re-calculate DO" End If 'Segment Derivative-06. ROT A//////////////////////////////////////////////////////////////////////// If Cells(m + 5, n + 3).Value = 6 Then ' rot A EqDelta = "$E$" & m + 6 ' Mix operators '------------------------------------------------------------------- If Cells(m + 7, n + 3).Value = "1st. DO:" Then VecN = Cells(m + 7, n + 4).Value If Cells(VecN * 9 - 1, n + 3).Value = 2 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 3 Then funName = " rot (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "< -- rot (" & Cells(VecN * 9 - 3, n).Value & ")" End If If Cells(VecN * 9 - 1, n + 3).Value = 4 Then funName = " rot (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "< -- rot (" & Cells(VecN * 9 - 3, n).Value & ")" End If If Cells(VecN * 9 - 1, n + 3).Value = 5 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 6 Then funName = " rot (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "< -- rot (" & Cells(VecN * 9 - 3, n).Value & ")" End If If Cells(VecN * 9 - 1, n + 3).Value = 7 Then funName = " rot (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "< -- rot (" & Cells(VecN * 9 - 3, n).Value & ")" End If If Cells(VecN * 9 - 1, n + 3).Value = 8 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If Else VecN = Cells(m + 7, n + 3).Value funName = " rot (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "< -- rot (" & Cells(VecN * 9 - 3, n).Value & ")" End If '------------------------------------------------------------------- 'End of mix operators 'Verifyif the target operator is a vector funtion If Cells(VecN * 9 - 2, n).Value <> 183 Then MsgBox "The field function to operate on is not vector function. Change the number of the target function in the selected cell. It must correspond to a vector function." Cells(m + 7, n + 3).Select GoTo out End If 'Define the components Cells(VecN * 9 + 3, n - 1) = Cells(VecN * 9 + 3, n - 1).Application.ConvertFormula(Cells(VecN * 9 + 3, n - 1).Formula, xlA1, xlA1, 1) Bx = Cells(VecN * 9 + 3, n - 1).Formula If Left(Bx, 1) = "=" Then 'do nothing Else Bx = "=" & Bx End If Cells(VecN * 9 + 3, n) = Cells(VecN * 9 + 3, n).Application.ConvertFormula(Cells(VecN * 9 + 3, n).Formula, xlA1, xlA1, 1) By = Cells(VecN * 9 + 3, n).Formula If Left(By, 1) = "=" Then 'do nothing Else By = "=" & By End If Cells(VecN * 9 + 3, n + 1) = Cells(VecN * 9 + 3, n + 1).Application.ConvertFormula(Cells(VecN * 9 + 3, n + 1).Formula, xlA1, xlA1, 1) Bz = Cells(VecN * 9 + 3, n + 1).Formula If Left(Bz, 1) = "=" Then 'do nothing Else Bz = "=" & Bz End If Bz = Replace(Bz, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Bz = Replace(Bz, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Bz = Replace(Bz, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Bz = Replace(Bz, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) By = Replace(By, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) By = Replace(By, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) By = Replace(By, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) By = Replace(By, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) Bx = Replace(Bx, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Bx = Replace(Bx, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Bx = Replace(Bx, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Bx = Replace(Bx, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) 'Calculate the components 'dBz/dy - dBy/dz = Eqx Eqz = Replace(Bz, "$B$" & m + 8, "($B$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqy = Replace(By, "$C$" & m + 8, "($C$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqx = Replace(Eqz, Eqz, "(" & Mid(Eqz, 2) & "-" & "(" & Mid(Bz, 2) & "))/(" & EqDelta & ")", 1, -1, 1) _ & "-" & Replace(Eqy, Eqy, "(" & Mid(Eqy, 2) & "-" & "(" & Mid(By, 2) & "))/(" & EqDelta & ")", 1, -1, 1) Cells(m + 9, n - 1).Value = "=" & Eqx 'dBx/dz - dBz/dx = Eqy Eqx = Replace(Bx, "$C$" & m + 8, "($C$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqz = Replace(Bz, "$A$" & m + 8, "($A$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqy = Replace(Eqx, Eqx, "(" & Mid(Eqx, 2) & "-" & "(" & Mid(Bx, 2) & "))/(" & EqDelta & ")", 1, -1, 1) _ & "-" & Replace(Eqz, Eqz, "(" & Mid(Eqz, 2) & "-" & "(" & Mid(Bz, 2) & "))/(" & EqDelta & ")", 1, -1, 1) Cells(m + 9, n).Value = "=" & Eqy 'dBy/dx - dBx/dy = Eqz Eqy = Replace(By, "$A$" & m + 8, "($A$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqx = Replace(Bx, "$B$" & m + 8, "($B$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqz = Replace(Eqy, Eqy, "(" & Mid(Eqy, 2) & "-" & "(" & Mid(By, 2) & "))/(" & EqDelta & ")", 1, -1, 1) _ & "-" & Replace(Eqx, Eqx, "(" & Mid(Eqx, 2) & "-" & "(" & Mid(Bx, 2) & "))/(" & EqDelta & ")", 1, -1, 1) Cells(m + 9, n + 1).Value = "=" & Eqz Cells(m + 8, n + 4).Value = "(Vector func.)" Cells(m + 3, n).FormulaR1C1 = funName Cells(m + 9, n + 2).Value = funName2 'Format Cells(m + 6, n - 1).Value = "" Cells(m + 6, n).Value = "" Cells(m + 8, n + 2).Value = "" Cells(m + 8, n + 3).Value = "" Cells(m + 11, n - 1).Value = 3 Cells(m + 4, n).Value = 183 ActiveSheet.Buttons(Application.Caller).Text = "Re-calculate DO" End If 'Segment Derivative-07. LAPLACIAN B//////////////////////////////////////////////////////////////////////// If Cells(m + 5, n + 3).Value = 7 Then ' Laplacian B (vector) EqDelta = "$E$" & m + 6 ' Mix operators '------------------------------------------------------------------- If Cells(m + 7, n + 3).Value = "1st. DO:" Then VecN = Cells(m + 7, n + 4).Value 'Verify the target operator If Cells(VecN * 9 - 1, n + 3).Value = 2 Then MsgBox "To calculate the laplacian of a scalar function select Laplacian (scalar U) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 3 Then funName = ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = " <-- " & ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ")" End If If Cells(VecN * 9 - 1, n + 3).Value = 4 Then funName = ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = " <-- " & ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ")" End If If Cells(VecN * 9 - 1, n + 3).Value = 5 Then MsgBox "To calculate the laplacian of a scalar function select Laplacian (scalar U) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 6 Then funName = ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = " <-- " & ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ")" End If If Cells(VecN * 9 - 1, n + 3).Value = 7 Then funName = ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = " <-- " & ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ")" End If If Cells(VecN * 9 - 1, n + 3).Value = 8 Then MsgBox "To calculate the laplacian of a scalar function select Laplacian (scalar U) ." GoTo out End If Else VecN = Cells(m + 7, n + 3).Value funName = ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = " <-- " & ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ")" End If '------------------------------------------------------------------- 'End of mix operators 'Verify if the target operator is vetorial If Cells(VecN * 9 - 2, n).Value <> 183 Then MsgBox "The field function to operate on is not vector function. Change the number of the target function in the selected cell. It must correspond to a vector function." Cells(m + 7, n + 3).Select GoTo out End If Cells(VecN * 9 + 3, n - 1) = Cells(VecN * 9 + 3, n - 1).Application.ConvertFormula(Cells(VecN * 9 + 3, n - 1).Formula, xlA1, xlA1, 1) Bx = Cells(VecN * 9 + 3, n - 1).Formula If Left(Bx, 1) = "=" Then Bx = Mid(Bx, 2) End If Cells(VecN * 9 + 3, n) = Cells(VecN * 9 + 3, n).Application.ConvertFormula(Cells(VecN * 9 + 3, n).Formula, xlA1, xlA1, 1) By = Cells(VecN * 9 + 3, n).Formula If Left(By, 1) = "=" Then By = Mid(By, 2) End If Cells(VecN * 9 + 3, n + 1) = Cells(VecN * 9 + 3, n + 1).Application.ConvertFormula(Cells(VecN * 9 + 3, n + 1).Formula, xlA1, xlA1, 1) Bz = Cells(VecN * 9 + 3, n + 1).Formula If Left(Bz, 1) = "=" Then Bz = Mid(Bz, 2) End If Bz = Replace(Bz, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Bz = Replace(Bz, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Bz = Replace(Bz, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Bz = Replace(Bz, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) By = Replace(By, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) By = Replace(By, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) By = Replace(By, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) By = Replace(By, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) Bx = Replace(Bx, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Bx = Replace(Bx, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Bx = Replace(Bx, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Bx = Replace(Bx, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) 'd^2Bx/dx^2 + d^2Bx/dy^2 + d^2Bx/dz^2 = Laplace_x = (B(x+h,y,z)-2B(x,y,z)+B(x-h,y,z))/h^2+... Eqx = Replace(Bx, "$A$" & m + 8, "($A$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) _ & "+" & Replace(Bx, "$A$" & m + 8, "($A$" & m + 8 & "-" & "$E$" & m + 6 & ")", 1, -1, 1) Eqy = Replace(Bx, "$B$" & m + 8, "($B$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) _ & "+" & Replace(Bx, "$B$" & m + 8, "($B$" & m + 8 & "-" & "$E$" & m + 6 & ")", 1, -1, 1) Eqz = Replace(Bx, "$C$" & m + 8, "($C$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) _ & "+" & Replace(Bx, "$C$" & m + 8, "($C$" & m + 8 & "-" & "$E$" & m + 6 & ")", 1, -1, 1) Cells(m + 9, n - 1).Value = "=(" & Eqx & "+" & Eqy & "+" & Eqz & "-6*(" & Bx & "))/(" & EqDelta & "^2)" 'd^2By/dx^2 + d^2By/dy^2 + d^2By/dz^2 = Laplace_y Eqx = Replace(By, "$A$" & m + 8, "($A$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) _ & "+" & Replace(By, "$A$" & m + 8, "($A$" & m + 8 & "-" & "$E$" & m + 6 & ")", 1, -1, 1) Eqy = Replace(By, "$B$" & m + 8, "($B$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) _ & "+" & Replace(By, "$B$" & m + 8, "($B$" & m + 8 & "-" & "$E$" & m + 6 & ")", 1, -1, 1) Eqz = Replace(By, "$C$" & m + 8, "($C$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) _ & "+" & Replace(By, "$C$" & m + 8, "($C$" & m + 8 & "-" & "$E$" & m + 6 & ")", 1, -1, 1) Cells(m + 9, n).Value = "=(" & Eqx & "+" & Eqy & "+" & Eqz & "-6*(" & By & "))/(" & EqDelta & "^2)" 'd^2Bz/dx^2 + d^2Bz/dy^2 + d^2Bz/dz^2 = Laplace_z Eqx = Replace(Bz, "$A$" & m + 8, "($A$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) _ & "+" & Replace(Bz, "$A$" & m + 8, "($A$" & m + 8 & "-" & "$E$" & m + 6 & ")", 1, -1, 1) Eqy = Replace(Bz, "$B$" & m + 8, "($B$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) _ & "+" & Replace(Bz, "$B$" & m + 8, "($B$" & m + 8 & "-" & "$E$" & m + 6 & ")", 1, -1, 1) Eqz = Replace(Bz, "$C$" & m + 8, "($C$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) _ & "+" & Replace(Bz, "$C$" & m + 8, "($C$" & m + 8 & "-" & "$E$" & m + 6 & ")", 1, -1, 1) Cells(m + 9, n + 1).Value = "=(" & Eqx & "+" & Eqy & "+" & Eqz & "-6*(" & Bz & "))/(" & EqDelta & "^2)" Cells(m + 8, n + 4).Value = "(Vector func.)" Cells(m + 3, n).FormulaR1C1 = funName Cells(m + 9, n + 2).Value = funName2 'Format Cells(m + 6, n - 1).Value = "" Cells(m + 6, n).Value = "" Cells(m + 8, n + 2).Value = "" Cells(m + 8, n + 3).Value = "" Cells(m + 11, n - 1).Value = 3 Cells(m + 4, n).Value = 183 ActiveSheet.Buttons(Application.Caller).Text = "Re-calculate DO" End If 'Segment Derivative-08. LAPLACIAN U//////////////////////////////////////////////////////////////////////// If Cells(m + 5, n + 3).Value = 8 Then ' Laplacian U (escalar) Eq = Cells(m + 7, n + 3).Formula EqDelta = "$E$" & m + 6 ' Mix operators '------------------------------------------------------------------- If Cells(m + 7, n + 3).Value = "1st. DO:" Then VecN = Cells(m + 7, n + 4).Value If Cells(VecN * 9 + 2, n + 3).Value = "" Then MsgBox "You should first compute the first differential operator." GoTo out End If Eq = Cells(VecN * 9 + 2, n + 3).Formula Eq = Replace(Eq, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) If Cells(VecN * 9 - 1, n + 3).Value = "" Then Cells(VecN * 9 - 1, n + 3).Value = Cells(m + 5, n + 3).Value End If If Cells(VecN * 9 - 1, n + 3).Value = 2 Then funName = ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ") =" End If If Cells(VecN * 9 - 1, n + 3).Value = 3 Then MsgBox "To calculate the laplacian of a vector function select Laplacian (vector A)." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 4 Then MsgBox "To calculate the laplacian of a vector function select Laplacian (vector A)." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 5 Then funName = ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ") =" End If If Cells(VecN * 9 - 1, n + 3).Value = 6 Then MsgBox "To calculate the laplacian of a vector function select Laplacian (vector A)." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 7 Then MsgBox "To calculate the laplacian of a vector function select Laplacian (vector A)." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 8 Then funName = ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = ChrW(8710) & " (" & Cells(VecN * 9 - 3, n).Value & ") =" End If Else Cells(m + 7, n + 3) = Cells(m + 7, n + 3).Application.ConvertFormula(Cells(m + 7, n + 3).Formula, xlA1, xlA1, 1) funName = ChrW(8710) & " U " funName2 = ChrW(8710) & " U =" End If '------------------------------------------------------------------- 'End of mix operators If Left(Eq, 1) = "=" Then Eq = Mid(Eq, 2) End If 'd^2U/dx^2 + d^2U/dy^2 + d^2U/dz^2 = Laplace U Eqx = Replace(Eq, "$A$" & m + 8, "($A$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) _ & "+" & Replace(Eq, "$A$" & m + 8, "($A$" & m + 8 & "-" & "$E$" & m + 6 & ")", 1, -1, 1) Eqy = Replace(Eq, "$B$" & m + 8, "($B$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) _ & "+" & Replace(Eq, "$B$" & m + 8, "($B$" & m + 8 & "-" & "$E$" & m + 6 & ")", 1, -1, 1) Eqz = Replace(Eq, "$C$" & m + 8, "($C$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) _ & "+" & Replace(Eq, "$C$" & m + 8, "($C$" & m + 8 & "-" & "$E$" & m + 6 & ")", 1, -1, 1) Cells(m + 8, n + 3).Value = "=(" & Eqx & "+" & Eqy & "+" & Eqz & "-6*(" & Eq & "))/(" & EqDelta & "^2)" Cells(m + 8, n + 4).Value = "(Scalar func.)" Cells(m + 3, n).FormulaR1C1 = funName Cells(m + 8, n + 2).Value = funName2 'Format Cells(m + 6, n - 1).Value = "" Cells(m + 6, n).Value = "" Cells(m + 9, n - 1).FormulaR1C1 = "=R[-1]C[4]" Cells(m + 9, n).FormulaR1C1 = "=R[-1]C[3]" Cells(m + 9, n + 1).FormulaR1C1 = "=R[-1]C[2]" Cells(m + 9, n + 2).Value = "" Cells(m + 11, n - 1).Value = 6 Cells(m + 4, n).Value = 146 ActiveSheet.Buttons(Application.Caller).Text = "Re-calculate DO" End If 'Segment Derivative-09. A grad) B//////////////////////////////////////////////////////////////////////// If Cells(m + 5, n + 3).Value = 9 Then ' (A grad) B EqDelta = "$E$" & m + 6 ' Mix operators: '------------------------------------------------------------------- If Cells(m + 7, n + 3).Value = "1st. DO:" Then VecN = Cells(m + 7, n + 4).Value If Cells(VecN * 9 - 1, n + 3).Value = "" Then Cells(VecN * 9 - 1, n + 3).Value = Cells(m + 5, n + 3).Value End If If Cells(VecN * 9 - 1, n + 3).Value = 2 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 3 Then funName = " div (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = " div (" & Cells(VecN * 9 - 3, n).Value & ") =" End If If Cells(VecN * 9 - 1, n + 3).Value = 4 Then funName = " (" & ChrW(8711) & ChrW(8729) & ChrW(8711) & ") " & Mid(Cells(VecN * 9 - 3, n).Value, 8, 1) funName2 = " (" & ChrW(8711) & ChrW(8729) & ChrW(8711) & ") " & Mid(Cells(VecN * 9 - 3, n).Value, 8, 1) & " =" End If If Cells(VecN * 9 - 1, n + 3).Value = 5 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 6 Then funName = " div (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "div (" & Cells(VecN * 9 - 3, n).Value & ") =" End If If Cells(VecN * 9 - 1, n + 3).Value = 7 Then funName = " div (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "div (" & Cells(VecN * 9 - 3, n).Value & ") =" End If If Cells(VecN * 9 - 1, n + 3).Value = 8 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If Else VecN = Cells(m + 7, n + 3).Value VecA = Cells(m + 7, n + 4).Value If VecA * VecN = 0 Then MsgBox " For this operation two vectors are needed. Please, indicate in cell " & Cells(m + 7, n + 3).Address(0, 0) & " the number of vector B and in cell " & Cells(m + 7, n + 4).Address(0, 0) & " the number of vector A, according to the operator (A grad ) B. " GoTo out End If funName = " (" & Cells(VecA * 9 - 3, n).Value & " grad)" & Cells(VecN * 9 - 3, n).Value funName2 = " <-- (" & Cells(VecA * 9 - 3, n).Value & " grad)" & Cells(VecN * 9 - 3, n).Value End If '------------------------------------------------------------------- 'End of mix operators 'Verify target operator If Cells(VecN * 9 - 2, n).Value <> 183 Or Cells(VecA * 9 - 2, n).Value <> 183 Then MsgBox "A field function to operate on is a scalar. Change the number of objective functions in the selected cells. They must both correspond to vector functions." ActiveSheet.Range(Cells(m + 7, n + 3), Cells(m + 7, n + 4)).Select GoTo out End If 'First vector field Cells(VecA * 9 + 3, n - 1) = Cells(VecA * 9 + 3, n - 1).Application.ConvertFormula(Cells(VecA * 9 + 3, n - 1).Formula, xlA1, xlA1, 1) Cells(VecA * 9 + 3, n) = Cells(VecA * 9 + 3, n).Application.ConvertFormula(Cells(VecA * 9 + 3, n).Formula, xlA1, xlA1, 1) Cells(VecA * 9 + 3, n + 1) = Cells(VecA * 9 + 3, n + 1).Application.ConvertFormula(Cells(VecA * 9 + 3, n + 1).Formula, xlA1, xlA1, 1) Ax = Cells(VecA * 9 + 3, n - 1).Formula Ay = Cells(VecA * 9 + 3, n).Formula Az = Cells(VecA * 9 + 3, n + 1).Formula If Left(Ax, 1) = "=" Then 'do nothing Else Ax = "=" & Ax End If If Left(Ay, 1) = "=" Then 'do nothing Else Ay = "=" & Ay End If If Left(Az, 1) = "=" Then 'do nothing Else Az = "=" & Az End If Ax = Mid(Ax, 2) Ay = Mid(Ay, 2) Az = Mid(Az, 2) Ax = Replace(Ax, "$A$" & VecA * 9 + 2, "$A$" & m + 8, 1, -1, 1) Ax = Replace(Ax, "$B$" & VecA * 9 + 2, "$B$" & m + 8, 1, -1, 1) Ax = Replace(Ax, "$C$" & VecA * 9 + 2, "$C$" & m + 8, 1, -1, 1) Ax = Replace(Ax, "$E$" & VecA * 9, "$E$" & m + 6, 1, -1, 1) Ay = Replace(Ay, "$A$" & VecA * 9 + 2, "$A$" & m + 8, 1, -1, 1) Ay = Replace(Ay, "$B$" & VecA * 9 + 2, "$B$" & m + 8, 1, -1, 1) Ay = Replace(Ay, "$C$" & VecA * 9 + 2, "$C$" & m + 8, 1, -1, 1) Ay = Replace(Ay, "$E$" & VecA * 9, "$E$" & m + 6, 1, -1, 1) Az = Replace(Az, "$A$" & VecA * 9 + 2, "$A$" & m + 8, 1, -1, 1) Az = Replace(Az, "$B$" & VecA * 9 + 2, "$B$" & m + 8, 1, -1, 1) Az = Replace(Az, "$C$" & VecA * 9 + 2, "$C$" & m + 8, 1, -1, 1) Az = Replace(Az, "$E$" & VecA * 9, "$E$" & m + 6, 1, -1, 1) 'Second field 'dBx/dx Cells(VecN * 9 + 3, n - 1) = Cells(VecN * 9 + 3, n - 1).Application.ConvertFormula(Cells(VecN * 9 + 3, n - 1).Formula, xlA1, xlA1, 1) Eq = Cells(VecN * 9 + 3, n - 1).Formula 'Bx coordinate If Left(Eq, 1) = "=" Then 'do nothing Else Eq = "=" & Eq End If Eq = Replace(Eq, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) Eqx = Replace(Eq, "$A$" & m + 8, "($A$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqx = Replace(Eqx, Eqx, "(" & Mid(Eqx, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) 'dBx/dy Eqy = Replace(Eq, "$B$" & m + 8, "($B$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqy = Replace(Eqy, Eqy, "(" & Mid(Eqy, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) 'dBx/dz Eqz = Replace(Eq, "$C$" & m + 8, "($C$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqz = Replace(Eqz, Eqz, "(" & Mid(Eqz, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) '[(A grad) B]_x= Ax dBx/dx + Ay dBx/dy + Az dBx/dz Cells(m + 9, n - 1).Value = "=(" & Ax & ")*(" & Eqx & ")+(" & Ay & ")*(" & Eqy & ")+(" & Az & ")*(" & Eqz & ")" 'dBy/dx Cells(VecN * 9 + 3, n) = Cells(VecN * 9 + 3, n).Application.ConvertFormula(Cells(VecN * 9 + 3, n).Formula, xlA1, xlA1, 1) Eq = Cells(VecN * 9 + 3, n).Formula 'By coordenadax del campo vectorial If Left(Eq, 1) = "=" Then 'do nothing Else Eq = "=" & Eq End If Eq = Replace(Eq, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) Eqx = Replace(Eq, "$A$" & m + 8, "($A$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqx = Replace(Eqx, Eqx, "(" & Mid(Eqx, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) 'dBy/dy Eqy = Replace(Eq, "$B$" & m + 8, "($B$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqy = Replace(Eqy, Eqy, "(" & Mid(Eqy, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) 'dBy/dz Eqz = Replace(Eq, "$C$" & m + 8, "($C$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqz = Replace(Eqz, Eqz, "(" & Mid(Eqz, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) '[(A grad) B]_y= Ax dBy/dx + Ay dBy/dy + Az dBy/dz Cells(m + 9, n).Value = "=(" & Ax & ")*(" & Eqx & ")+(" & Ay & ")*(" & Eqy & ")+(" & Az & ")*(" & Eqz & ")" 'dBz/dx Cells(VecN * 9 + 3, n + 1) = Cells(VecN * 9 + 3, n + 1).Application.ConvertFormula(Cells(VecN * 9 + 3, n + 1).Formula, xlA1, xlA1, 1) Eq = Cells(VecN * 9 + 3, n + 1).Formula 'Bz coordenadax del campo vectorial If Left(Eq, 1) = "=" Then 'do nothing Else Eq = "=" & Eq End If Eq = Replace(Eq, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Eq = Replace(Eq, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) Eqx = Replace(Eq, "$A$" & m + 8, "($A$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqx = Replace(Eqx, Eqx, "(" & Mid(Eqx, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) 'dBz/dy Eqy = Replace(Eq, "$B$" & m + 8, "($B$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqy = Replace(Eqy, Eqy, "(" & Mid(Eqy, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) 'dBz/dz Eqz = Replace(Eq, "$C$" & m + 8, "($C$" & m + 8 & "+" & "$E$" & m + 6 & ")", 1, -1, 1) Eqz = Replace(Eqz, Eqz, "(" & Mid(Eqz, 2) & "-" & "(" & Mid(Eq, 2) & "))/(" & EqDelta & ")", 1, -1, 1) 'Put the result '[(A grad) B]_z= Ax dBz/dx + Ay dBz/dy + Az dBz/dz Cells(m + 9, n + 1).Value = "=(" & Ax & ")*(" & Eqx & ")+(" & Ay & ")*(" & Eqy & ")+(" & Az & ")*(" & Eqz & ")" Cells(m + 8, n + 4).Value = "(Vector func.)" Cells(m + 9, n + 2).Value = funName2 Cells(m + 3, n).Value = funName 'Format Cells(m + 8, n + 3).Value = "" Cells(m + 8, n + 2).Value = "" Cells(m + 11, n - 1).Value = 3 Cells(m + 4, n).Value = 183 ActiveSheet.Buttons(Application.Caller).Text = "Re-calculate DO" End If 'Segment Derivative-10. (A B)//////////////////////////////////////////////////////////////////////// If Cells(m + 5, n + 3).Value = 10 Then ' (A B) ' Mix operators '------------------------------------------------------------------- If Cells(m + 7, n + 3).Value = "1st. DO:" Then VecN = Cells(m + 7, n + 4).Value If Cells(VecN * 9 - 1, n + 3).Value = "" Then Cells(VecN * 9 - 1, n + 3).Value = Cells(m + 5, n + 3).Value End If If Cells(VecN * 9 - 1, n + 3).Value = 2 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 3 Then funName = " div (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = " div (" & Cells(VecN * 9 - 3, n).Value & ") =" End If If Cells(VecN * 9 - 1, n + 3).Value = 4 Then ' funName = " (" & ChrW(8711) & ChrW(8729) & ChrW(8711) & ") " & Mid(Cells(VecN * 9 - 3, n).Value, 8, 1) funName2 = " (" & ChrW(8711) & ChrW(8729) & ChrW(8711) & ") " & Mid(Cells(VecN * 9 - 3, n).Value, 8, 1) & " =" End If If Cells(VecN * 9 - 1, n + 3).Value = 5 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 6 Then ' funName = " div (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "div (" & Cells(VecN * 9 - 3, n).Value & ") =" End If If Cells(VecN * 9 - 1, n + 3).Value = 7 Then funName = " div (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "div (" & Cells(VecN * 9 - 3, n).Value & ") =" End If If Cells(VecN * 9 - 1, n + 3).Value = 8 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If Else VecN = Cells(m + 7, n + 3).Value VecA = Cells(m + 7, n + 4).Value If VecA * VecN = 0 Then MsgBox " For this operation two vectors are needed. Please, indicate in cell " & Cells(m + 7, n + 3).Address & " the number of vector B and in cell " & Cells(m + 7, n + 4).Address & " the number of vector A, according to the scalar product (A B). " GoTo out End If funName = " (" & Cells(VecA * 9 - 3, n).Value & " " & Cells(VecN * 9 - 3, n).Value & ") " funName2 = " (" & Cells(VecA * 9 - 3, n).Value & " " & Cells(VecN * 9 - 3, n).Value & ") -->" End If '------------------------------------------------------------------- 'End of mix operators 'Verify target functions If Cells(VecN * 9 - 2, n).Value <> 183 Or Cells(VecA * 9 - 2, n).Value <> 183 Then 'verificar cual es el operador anterior MsgBox "A field function to operate on is a scalar. Change the number of objective functions in the selected cells. They must both correspond to vector functions." ActiveSheet.Range(Cells(m + 7, n + 3), Cells(m + 7, n + 4)).Select GoTo out End If 'First vector function Cells(VecA * 9 + 3, n - 1) = Cells(VecA * 9 + 3, n - 1).Application.ConvertFormula(Cells(VecA * 9 + 3, n - 1).Formula, xlA1, xlA1, 1) 'conversion a formual absoluta Cells(VecA * 9 + 3, n) = Cells(VecA * 9 + 3, n).Application.ConvertFormula(Cells(VecA * 9 + 3, n).Formula, xlA1, xlA1, 1) 'conversion a formual absoluta Cells(VecA * 9 + 3, n + 1) = Cells(VecA * 9 + 3, n + 1).Application.ConvertFormula(Cells(VecA * 9 + 3, n + 1).Formula, xlA1, xlA1, 1) 'conversion a formual absoluta Ax = Cells(VecA * 9 + 3, n - 1).Formula Ay = Cells(VecA * 9 + 3, n).Formula Az = Cells(VecA * 9 + 3, n + 1).Formula If Left(Ax, 1) = "=" Then 'do nothing Else Ax = "=" & Ax End If If Left(Ay, 1) = "=" Then 'do nothing Else Ay = "=" & Ay End If If Left(Az, 1) = "=" Then 'do nothing Else Az = "=" & Az End If Ax = Mid(Ax, 2) Ay = Mid(Ay, 2) Az = Mid(Az, 2) Ax = Replace(Ax, "$A$" & VecA * 9 + 2, "$A$" & m + 8, 1, -1, 1) Ax = Replace(Ax, "$B$" & VecA * 9 + 2, "$B$" & m + 8, 1, -1, 1) Ax = Replace(Ax, "$C$" & VecA * 9 + 2, "$C$" & m + 8, 1, -1, 1) Ax = Replace(Ax, "$E$" & VecA * 9, "$E$" & m + 6, 1, -1, 1) Ay = Replace(Ay, "$A$" & VecA * 9 + 2, "$A$" & m + 8, 1, -1, 1) Ay = Replace(Ay, "$B$" & VecA * 9 + 2, "$B$" & m + 8, 1, -1, 1) Ay = Replace(Ay, "$C$" & VecA * 9 + 2, "$C$" & m + 8, 1, -1, 1) Ay = Replace(Ay, "$E$" & VecA * 9, "$E$" & m + 6, 1, -1, 1) Az = Replace(Az, "$A$" & VecA * 9 + 2, "$A$" & m + 8, 1, -1, 1) Az = Replace(Az, "$B$" & VecA * 9 + 2, "$B$" & m + 8, 1, -1, 1) Az = Replace(Az, "$C$" & VecA * 9 + 2, "$C$" & m + 8, 1, -1, 1) Az = Replace(Az, "$E$" & VecA * 9, "$E$" & m + 6, 1, -1, 1) 'Second function Cells(VecN * 9 + 3, n - 1) = Cells(VecN * 9 + 3, n - 1).Application.ConvertFormula(Cells(VecN * 9 + 3, n - 1).Formula, xlA1, xlA1, 1) 'conversion a formual absoluta Cells(VecN * 9 + 3, n) = Cells(VecN * 9 + 3, n).Application.ConvertFormula(Cells(VecN * 9 + 3, n).Formula, xlA1, xlA1, 1) 'conversion a formual absoluta Cells(VecN * 9 + 3, n + 1) = Cells(VecN * 9 + 3, n + 1).Application.ConvertFormula(Cells(VecN * 9 + 3, n + 1).Formula, xlA1, xlA1, 1) 'conversion a formual absoluta Bx = Cells(VecN * 9 + 3, n - 1).Formula By = Cells(VecN * 9 + 3, n).Formula Bz = Cells(VecN * 9 + 3, n + 1).Formula If Left(Bx, 1) = "=" Then 'do nothing Else Bx = "=" & Bx End If If Left(By, 1) = "=" Then 'do nothing Else By = "=" & By End If If Left(Bz, 1) = "=" Then 'do nothing Else Bz = "=" & Bz End If Bx = Mid(Bx, 2) By = Mid(By, 2) Bz = Mid(Bz, 2) Bx = Replace(Bx, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Bx = Replace(Bx, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Bx = Replace(Bx, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Bx = Replace(Bx, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) By = Replace(By, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) By = Replace(By, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) By = Replace(By, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) By = Replace(By, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) Bz = Replace(Bz, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Bz = Replace(Bz, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Bz = Replace(Bz, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Bz = Replace(Bz, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) 'Put the result Cells(m + 8, n + 3).Value = "=(" & Ax & ")*(" & Bx & ")+(" & Ay & ")*(" & By & ")+(" & Az & ")*(" & Bz & ")" Cells(m + 8, n + 4).Value = "(Scalar func.)" Cells(m + 8, n + 2).Value = funName2 Cells(m + 3, n).Value = funName 'Format Cells(m + 9, n - 1).FormulaR1C1 = "=R[-1]C[4]" Cells(m + 9, n).FormulaR1C1 = "=R[-1]C[3]" Cells(m + 9, n + 1).FormulaR1C1 = "=R[-1]C[2]" Cells(m + 9, n + 2).Value = "" Cells(m + 11, n - 1).Value = 6 Cells(m + 4, n).Value = 146 ActiveSheet.Buttons(Application.Caller).Text = "Re-calculate DO" End If 'Segment Derivative-11. (A x B)//////////////////////////////////////////////////////////////////////// If Cells(m + 5, n + 3).Value = 11 Then ' (A x B) ' Mix operators '------------------------------------------------------------------- If Cells(m + 7, n + 3).Value = "1st. DO:" Then VecN = Cells(m + 7, n + 4).Value ' 'Verify the target operator If Cells(VecN * 9 - 1, n + 3).Value = "" Then Cells(VecN * 9 - 1, n + 3).Value = Cells(m + 5, n + 3).Value End If If Cells(VecN * 9 - 1, n + 3).Value = 2 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 3 Then funName = " div (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = " div (" & Cells(VecN * 9 - 3, n).Value & ") =" End If If Cells(VecN * 9 - 1, n + 3).Value = 4 Then ' funName = " (" & ChrW(8711) & ChrW(8729) & ChrW(8711) & ") " & Mid(Cells(VecN * 9 - 3, n).Value, 8, 1) funName2 = " (" & ChrW(8711) & ChrW(8729) & ChrW(8711) & ") " & Mid(Cells(VecN * 9 - 3, n).Value, 8, 1) & " =" End If If Cells(VecN * 9 - 1, n + 3).Value = 5 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If If Cells(VecN * 9 - 1, n + 3).Value = 6 Then funName = " div (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "div (" & Cells(VecN * 9 - 3, n).Value & ") =" End If If Cells(VecN * 9 - 1, n + 3).Value = 7 Then funName = " div (" & Cells(VecN * 9 - 3, n).Value & ")" funName2 = "div (" & Cells(VecN * 9 - 3, n).Value & ") =" End If If Cells(VecN * 9 - 1, n + 3).Value = 8 Then MsgBox "To calculate the derivative of a scalar function select grad (scalar U) ." GoTo out End If Else VecN = Cells(m + 7, n + 3).Value VecA = Cells(m + 7, n + 4).Value If VecA * VecN = 0 Then MsgBox " For this operation two vectors are needed. Please, indicate in cell " & Cells(m + 7, n + 3).Address & " the number of vector B and in cell " & Cells(m + 7, n + 4).Address & " the number of vector A, according to the vector product [A x B]. " GoTo out End If 'Labels: funName = " [" & Cells(VecA * 9 - 3, n).Value & " x " & Cells(VecN * 9 - 3, n).Value & "] " funName2 = " <-- [" & Cells(VecA * 9 - 3, n).Value & " x " & Cells(VecN * 9 - 3, n).Value & "] " End If '------------------------------------------------------------------- 'End of mix operators 'Verify if the target functions are vectors If Cells(VecN * 9 - 2, n).Value <> 183 Or Cells(VecA * 9 - 2, n).Value <> 183 Then 'verificar cual es el operador anterior MsgBox "A field function to operate on is a scalar. Change the number of objective functions in the selected cells. They must both correspond to vector functions." ActiveSheet.Range(Cells(m + 7, n + 3), Cells(m + 7, n + 4)).Select GoTo out End If 'First field Cells(VecA * 9 + 3, n - 1) = Cells(VecA * 9 + 3, n - 1).Application.ConvertFormula(Cells(VecA * 9 + 3, n - 1).Formula, xlA1, xlA1, 1) 'conversion a formual absoluta Cells(VecA * 9 + 3, n) = Cells(VecA * 9 + 3, n).Application.ConvertFormula(Cells(VecA * 9 + 3, n).Formula, xlA1, xlA1, 1) 'conversion a formual absoluta Cells(VecA * 9 + 3, n + 1) = Cells(VecA * 9 + 3, n + 1).Application.ConvertFormula(Cells(VecA * 9 + 3, n + 1).Formula, xlA1, xlA1, 1) 'conversion a formual absoluta Ax = Cells(VecA * 9 + 3, n - 1).Formula Ay = Cells(VecA * 9 + 3, n).Formula Az = Cells(VecA * 9 + 3, n + 1).Formula If Left(Ax, 1) = "=" Then 'do nothing Else Ax = "=" & Ax End If If Left(Ay, 1) = "=" Then 'do nothing Else Ay = "=" & Ay End If If Left(Az, 1) = "=" Then 'do nothing Else Az = "=" & Az End If Ax = Mid(Ax, 2) Ay = Mid(Ay, 2) Az = Mid(Az, 2) Ax = Replace(Ax, "$A$" & VecA * 9 + 2, "$A$" & m + 8, 1, -1, 1) Ax = Replace(Ax, "$B$" & VecA * 9 + 2, "$B$" & m + 8, 1, -1, 1) Ax = Replace(Ax, "$C$" & VecA * 9 + 2, "$C$" & m + 8, 1, -1, 1) Ax = Replace(Ax, "$E$" & VecA * 9, "$E$" & m + 6, 1, -1, 1) Ay = Replace(Ay, "$A$" & VecA * 9 + 2, "$A$" & m + 8, 1, -1, 1) Ay = Replace(Ay, "$B$" & VecA * 9 + 2, "$B$" & m + 8, 1, -1, 1) Ay = Replace(Ay, "$C$" & VecA * 9 + 2, "$C$" & m + 8, 1, -1, 1) Ay = Replace(Ay, "$E$" & VecA * 9, "$E$" & m + 6, 1, -1, 1) Az = Replace(Az, "$A$" & VecA * 9 + 2, "$A$" & m + 8, 1, -1, 1) Az = Replace(Az, "$B$" & VecA * 9 + 2, "$B$" & m + 8, 1, -1, 1) Az = Replace(Az, "$C$" & VecA * 9 + 2, "$C$" & m + 8, 1, -1, 1) Az = Replace(Az, "$E$" & VecA * 9, "$E$" & m + 6, 1, -1, 1) 'Second field Cells(VecN * 9 + 3, n - 1) = Cells(VecN * 9 + 3, n - 1).Application.ConvertFormula(Cells(VecN * 9 + 3, n - 1).Formula, xlA1, xlA1, 1) ' A to $A$, etc Cells(VecN * 9 + 3, n) = Cells(VecN * 9 + 3, n).Application.ConvertFormula(Cells(VecN * 9 + 3, n).Formula, xlA1, xlA1, 1) ' Cells(VecN * 9 + 3, n + 1) = Cells(VecN * 9 + 3, n + 1).Application.ConvertFormula(Cells(VecN * 9 + 3, n + 1).Formula, xlA1, xlA1, 1) ' Bx = Cells(VecN * 9 + 3, n - 1).Formula By = Cells(VecN * 9 + 3, n).Formula Bz = Cells(VecN * 9 + 3, n + 1).Formula If Left(Bx, 1) = "=" Then 'do nothing Else Bx = "=" & Bx End If If Left(By, 1) = "=" Then 'do nothing Else By = "=" & By End If If Left(Bz, 1) = "=" Then 'do nothing Else Bz = "=" & Bz End If Bx = Mid(Bx, 2) By = Mid(By, 2) Bz = Mid(Bz, 2) Bx = Replace(Bx, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Bx = Replace(Bx, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Bx = Replace(Bx, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Bx = Replace(Bx, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) By = Replace(By, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) By = Replace(By, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) By = Replace(By, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) By = Replace(By, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) Bz = Replace(Bz, "$A$" & VecN * 9 + 2, "$A$" & m + 8, 1, -1, 1) Bz = Replace(Bz, "$B$" & VecN * 9 + 2, "$B$" & m + 8, 1, -1, 1) Bz = Replace(Bz, "$C$" & VecN * 9 + 2, "$C$" & m + 8, 1, -1, 1) Bz = Replace(Bz, "$E$" & VecN * 9, "$E$" & m + 6, 1, -1, 1) 'Put the result Cells(m + 9, n - 1).Value = "=(" & Ay & ")*(" & Bz & ")-(" & By & ")*(" & Az & ")" Cells(m + 9, n).Value = "=(" & Az & ")*(" & Bx & ")-(" & Bz & ")*(" & Ax & ")" Cells(m + 9, n + 1).Value = "=(" & Ax & ")*(" & By & ")-(" & Bx & ")*(" & Ay & ")" Cells(m + 8, n + 4).Value = "(Vector func.)" Cells(m + 9, n + 2).Value = funName2 Cells(m + 3, n).Value = funName 'Format Cells(m + 8, n + 3).Value = "" Cells(m + 8, n + 2).Value = "" Cells(m + 11, n - 1).Value = 3 Cells(m + 4, n).Value = 183 ActiveSheet.Buttons(Application.Caller).Text = "Re-calculate DO" End If out: End If ' End of n=2 Rotate ' Refresh the results End Sub