# loaddefs link d_Qnial_mine 'matrix derivatives in [cartesian, cylindrical, spherical] coordinates.ndf' https://en.wikipedia.org/wiki/Vector_fields_in_cylindrical_and_spherical_coordinates Reminder - vector orientations ar VERTICAL unless modified by "_T" (transpose operator). # www.BillHowell.ca 27Mar2016 start # example see '/media/bill/SWAPPER/Lucas - Universal Force/time derivatives for Lucas Chap4.ndf' f_matDer := 'matrix derivatives in [cartesian, cylindrical, spherical] coordinates.ndf' ; loaddefs_start f_matDer ; lq_matrix IS loaddefs link d_matrix f_matDer #**************************** # List of operators, generated with : # $ cat "$d_Qndfs""matrix derivatives in [cartesian, cylindrical, spherical] coordinates.ndf" | grep "^#]" | sed 's/^#\]/ /' # ***************************************************** Conversion of coordinates [Cartesian, cylindrical, spherical] RF_convert_crt_to_cyl IS OP vector_cartesian for 0 <= θ < 2*π RF_convert_cyl_to_crt IS OP vector_cylindrical - RF_convert_crt_to_sph IS OP vector_cartesian - for 0 <= θ <= π ; 0 <= φ < 2*π RF_convert_sph_to_crt IS OP vector_spherical RF_convert IS OP vector RF_desired - ******************** Time derivatives dp_dt_cartesian IS OP vector_cartesian - dp2_dt2_cartesian IS OP vector_cartesian - dp_dt_cylindrical IS OP vector_cylindrical dp2_dt2_cylindrical IS OP vector_cylindrical dp_dt_spherical IS OP vector_spherical - #*********** # Reminder of debug setup... flag_break := o ; flag_check := o ; flag_debug := o ; # IF flag_break = l THEN Break ; ENDIF ; # IF flag_print = l THEN <... coding for printout ...> ; ENDIF ; program_break IS { IF flag_break = l THEN Break ; ENDIF ; } # Faults occur normally during searches, and must not stop execution! settrigger o ; # watch : awesome eQNial power!! X gets count 5; watch !x 'write ''X changed to: '' X' #************************************************** # Setup Qnial_mine := d_Qnial_mine ; IF not in "WRITE_PARENTHESIS_ALIGNED (EACH first symbols 0) THEN loaddefs (link d_Qnial_mine 'matrix operations - symbolic & real-valued.ndf') 0 ; loaddefs (link d_Qnial_mine 'matrix - symbolic reduction.ndf') 0 ; loaddefs (link d_Qnial_mine 'matrix - write with parenthesis aligned.ndf') 0 ; ENDIF; #]***************************************************** #] Conversion of coordinates [Cartesian, cylindrical, spherical] In essence, the orthogonal vector frameworks for the [cartesian, cylindrical,spherical] coordinate systems are ALL cartesian unit vectors. The [cylindrical,spherical] are convenient means of handling their respective symmetries, but they must be based on their respective orthogonal vector basis, which are essentially cartesian. # Based on : https://en.wikipedia.org/wiki/Vector_fields_in_cylindrical_and_spherical_coordinates#Spherical_coordinate_system Note: the matrix is an orthogonal matrix, that is, its inverse is simply its transpose. # "Vector field" = Howell's "Coordinate reference frame" : What this wiki article calls a vector field, I have been calling a coordinate reference frame. Note that all the vector fields in this wiki article are cartesian. # Let RF_ denote a coordinate frame : eg RF_spherical, RF_cartesian, RF_cylindrical From "Howell - Variables, notations, styles for Bill Lucas, Universal Force.odt" let the modifier : - "h" denot a unit vectof, % Orthogonal coordinate reference frames ; RF_cartesian := 3 1 reshape 'xh' 'yh' 'zh' ; RF_cylindrical := 3 1 reshape 'rh' 'θh' 'zh' ; RF_spherical := 3 1 reshape 'ρh' 'θh' 'φh' ; # NOTE: NOT stated by the wiki article is that thes relations ONLY hold for [coincident, aligned] reference frames!!! This is extremely important... #] RF_convert_crt_to_cyl IS OP vector_cartesian for 0 <= θ < 2*π RF_convert_crt_to_cyl IS OP vector_cartesian { x y z := vector_cartesian ; shape vector_cartesian reshape (link 'sqrt(' x '*' x ' + ' y '*' y ')') (link 'arctan(' y '/' x ')') z } #] RF_convert_cyl_to_crt IS OP vector_cylindrical - RF_convert_cyl_to_crt IS OP vector_cylindrical { r theta z := vector_cylindrical ; shape vector_cylindrical reshape (link r '*cos(' theta ')') (link r '*sin(' theta ')') z } # here "RUV" denotes unit vector RUV RUV_converTable_crt_to_cyl := 3 3 reshape 'cos(θ)' 'sin(θ)' '0' '-sin(θ)' 'cos(θ)' '0' '0' '0' '1' ; RUV_converTable_cyl_to_crt := transpose RUV_converTable_crt_to_cyl ; #] RF_convert_crt_to_sph IS OP vector_cartesian - for 0 <= θ <= π ; 0 <= φ < 2*π RF_convert_crt_to_sph IS OP vector_cartesian { x y z := vector_cartesian ; rho := link 'sqrt(' x '*' x ' + ' y '*' y ' + ' z '*' z ')' ; shape vector_cartesian reshape rho (link 'arccos(' z '/' rho ')') (link 'arctan(' y '/' z ')') } #] RF_convert_sph_to_crt IS OP vector_spherical RF_convert_sph_to_crt IS OP vector_spherical { rho theta phi := vector_spherical ; shape vector_spherical reshape (link rho '*sin(' theta ')*cos(' phi ')') (link rho '*sin(' theta ')*sin(' phi ')') (link rho '*cos(' theta ')') } RUV_converTable_crt_to_sph := 3 3 reshape 'sin(θ)*cos(φ)' 'sin(θ)*sin(φ)' 'cos(θ)' 'cos(θ)*cos(φ)' 'cos(θ)*sin(φ)' '-sin(θ)' '-sin(φ)' 'cos(φ)' '0' ; RUV_converTable_sph_to_crt := transpose RUV_converTable_crt_to_sph ; #] RF_convert IS OP vector RF_desired - RF_convert IS OP vector RF_desired { IF = RF_desired "cylindrical THEN '' ; ENDIF ; } #]******************** #] Time derivatives # as per wiki article - elaborated here # Vector field A moving but with repect to WHAT???? as own coordinate frame is moving! # translation & rotation 3-axis? - not with Cartesian version! translation only? # spherical coordinates, ?NON-ROTATING?, remember that the unit vectors are orthogonal basis (Cartesian) : dp[dt : A] = dp[dt : Aρ*ρh + Aθ*θh + Aφ*φh] = dp[dt : Aρ*ρh] + dp[dt : Aθ*θh] + dp[dt : Aφ*φh] 1) = dp[dt : Aρ]*ρh + Aρ*dp[dt : ρh] + dp[dt : Aθ]*θh + Aθ*dp[dt : θh] + dp[dt : Aφ]*φh + Aφ*dp[dt : φh] # This is the same as for the wiki-page. # For time derivatives of the unit vectors, as their magnitudes never change (= 1), the derivative for each unit vector arises from its rotation and translation wrt to the "other two axis" : # (I need to do an illustration here!) - ??? RE-DERIVE THIS! 2) dp[dt : ρh] = dp[dt : θ] *θh + dp[dt : φ]*sinθ*φh 3) dp[dt : θh] = -dp[dt : θ] *ρh + dp[dt : φ]*cosθ*φh 4) dp[dt : φh] = -dp[dt : φ]*sinθ*ρh - dp[dt : φ]*cosθ*θh # Subbing (2),(3),(4) into (1) : dp[dt : A] = dp[dt : Aρ]*ρh + Aρ*dp[dt : ρh] + dp[dt : Aθ]*θh + Aθ*dp[dt : θh] + dp[dt : Aφ]*φh + Aφ*dp[dt : φh] = dp[dt : Aρ]*ρh + Aρ*{ dp[dt : θ] *θh + dp[dt : φ]*sinθ*φh} + dp[dt : Aθ]*θh + Aθ*{-dp[dt : θ] *ρh + dp[dt : φ]*cosθ*φh} + dp[dt : Aφ]*φh + Aφ*{-dp[dt : φ]*sinθ*ρh - dp[dt : φ]*cosθ*θh} = dp[dt : Aρ]*ρh + Aρ*dp[dt : θ]*θh + Aρ*dp[dt : φ]*sinθ*φh + dp[dt : Aθ]*θh - Aθ*dp[dt : θ]*ρh + Aθ*dp[dt : φ]*cosθ*φh + dp[dt : Aφ]*φh + Aφ*-dp[dt : φ]*sinθ*ρh - Aφ*dp[dt : φ]*cosθ*θh = dp[dt : Aρ] *ρh - Aθ*dp[dt : θ] *ρh - Aφ*dp[dt : φ]*sinθ*ρh + Aρ*dp[dt : θ] *θh + dp[dt : Aθ] *θh - Aφ*dp[dt : φ]*cosθ*θh + Aρ*dp[dt : φ]*sinθ*φh + Aθ*dp[dt : φ]*cosθ*φh + dp[dt : Aφ] *φh = ρh*{ dp[dt : Aρ] - Aθ*dp[dt : θ] - Aφ*dp[dt : φ]*sinθ } + θh*{ Aρ*dp[dt : θ] + dp[dt : Aθ] - Aφ*dp[dt : φ]*cosθ } + φh*{ Aρ*dp[dt : φ]*sinθ + Aθ*dp[dt : φ]*cosθ + dp[dt : Aφ] } # Finally : 5) dp[dt : A] = ρh*{ dp[dt : Aρ] - Aθ*dp[dt : θ] - Aφ*dp[dt : φ]*sinθ } + θh*{ dp[dt : Aθ] + Aρ*dp[dt : θ] - Aφ*dp[dt : φ]*cosθ } + φh*{ dp[dt : Aφ] + Aρ*dp[dt : φ]*sinθ + Aθ*dp[dt : φ]*cosθ } # This is the same as for the wiki-page. dp_dt IS OP texter { link 'dp[dt : ' texter ' ]' } dp2_dt2 IS OP texter { link 'dp2[dt2 : ' texter ' ]' } #] dp_dt_cartesian IS OP vector_cartesian - dp_dt_cartesian IS OP vector_cartesian { mms (transpose EACH dp_dt vector_cartesian) RF_cartesian } #] dp2_dt2_cartesian IS OP vector_cartesian - dp2_dt2_cartesian IS OP vector_cartesian { mms (transpose EACH dp2_dt2 vector_cartesian) RF_cartesian } #] dp_dt_cylindrical IS OP vector_cylindrical dp_dt_cylindrical IS OP vector_cylindrical { r theta z := vector_cylindrical ; Ar Atheta Az := RF_convert_cyl_to_crt r theta z ; mms ( 1 3 reshape (link '( dp[dt : ' Ar '] - ' Atheta '*dp[dt : ' theta '])' ) (link '( dp[dt : ' Atheta '] + ' Ar '*dp[dt : ' theta '])' ) (link 'dp[dt : ' Az ']' ) ) RF_cylindrical } #] dp2_dt2_cylindrical IS OP vector_cylindrical dp2_dt2_cylindrical IS OP vector_cylindrical { r theta z := vector_cylindrical ; Ar Atheta Az := RF_convert_cyl_to_crt r theta z ; mms ( 1 3 reshape (link '( dp2[dt2 : ' Ar '] - ' Atheta '*dp2[dt2 : ' theta '] - 2*dp[dt : ' Atheta ']*dp[dt : ' theta '] - ' Ar '*dp[dt : ' theta ']^2)' ) (link '( dp2[dt2 : ' Atheta '] + ' Ar '*dp2[dt2 : ' theta '] + 2*dp[dt : ' Ar ']*dp[dt : ' theta '] - ' Atheta '*dp[dt : ' theta ']^2)' ) (link 'dp2[dt2 : ' Az ']' ) ) RF_cylindrical } # https://en.wikipedia.org/wiki/Vector_fields_in_cylindrical_and_spherical_coordinates#Spherical_coordinate_system # IMPORTANT!!! Note that for cylindrical coordinates : # dp2[dt2 : r] *rh = central outward acceleration # -r*dp [dt : θ]^2 *rh = centripetal acceleration # r*dp2[dt2 : θ] *θh = angular acceleration # 2*dp [dt : r*sinθ]*dp[dt : θ] *θh = Coriolis acceleration # dp2[dt2 : z] *zh = z acceleration #] dp_dt_spherical IS OP vector_spherical - dp_dt_spherical IS OP vector_spherical { r theta phi := vector_spherical ; Arho Atheta Aphi := RF_convert_sph_to_crt r theta phi ; mms ( 1 3 reshape (link '( dp[dt : ' Arho '] - ' Atheta '*dp[dt : ' theta ']' ' - ' Aphi '*dp[dt : ' phi ']*sin(' theta '))' ) (link '( dp[dt : ' Atheta '] + ' Arho '*dp[dt : ' theta ']' ' - ' Aphi '*dp[dt : ' phi ']*cos(' theta '))' ) (link '( dp[dt : ' Aphi '] + ' Arho '*dp[dt : ' phi ']*sin(' theta ') + ' Atheta '*dp[dt : ' phi ']*cos(' theta '))' ) ) RF_spherical } # dp2_dt2_spherical IS OP vector_spherical # No expression on wiki page !!! # This is just a placeholder... #************************* # derivatives of [scalar, vector, matrix] norms # eg Kahan formulation write link '<<<<< done loading ' f_matDer ; # enddoc