Contains function. These are:
formula-term
formula-eqn-side
formula-eqn-side-manifold
(require '[diman.formula :refer [formula-term formula-eqn-side formula-eqn-side-manifold]])
Given
(def varpars [{:symbol "x", :quantity "length"}
{:symbol "v", :quantity "velocity"}
{:symbol "t", :quantity "time"}
{:symbol "a", :quantity "acceleration"}])
(def lhs "x^(1)")
(def rhs {:term1 "x^(1)", :term2 "v^(2)", :term3 "t^(1)", :term4 "0.5*a^(1)*t^(2)"})
(def eqn {:lhs lhs, :rhs rhs})
To get the formula of a term, say, (:term4 rhs)
=> (formula-term varpars (:term4 rhs))
"[T^(0)*L^(1)]"
and for left hand side
=> (formula-term varpars lhs)
"[L^(1)]"
For right hand side
=> (formula-eqn-side varpars rhs)
"[L^(1)] + [T^(-2)*L^(2)] + [T^(1)] + [T^(0)*L^(1)]"
for left hand side
=> (formula-eqn-side varpars lhs)
"[L^(1)]"
Lets say we have two different equations
(def p_leftside "p^(1)")
(def p_rightside {:term1 "x^(2)*v^(-1)*t^(1)"})
(def p_equation {:lhs p_leftside, :rhs p_rightside})
and
(def q_leftside "q^(1)")
(def q_rightside {:term1 "x^(1)*a^(6)*t^(20)"})
(def q_equation {:lhs q_leftside, :rhs q_rightside})
The RHS of the above two equations can be evaluated in one step using
formula-eqn-side-manifold
. To do this let us set up its argument
(def manifold_eqn [{:name "p_quantity" :eqn (:rhs p_equation)}
{:name "q_quantity" :eqn (:rhs q_equation)}])
Now we may invoke the method by passing the above as the argument
=> (formula-eqn-side-manifold varpars manifold_eqn)
[{:quantity "p_quantity", :dimension "[L^(-1)*L^(2)*T^(2)]"}
{:quantity "q_quantity", :dimension "[L^(6)*T^(8)*L^(1)]"}]
NOTE: If the user plans to insert these derived dimensional formulae into
the standard_formula
the name given for respective :quantity
in the above
argument (here we named it manifold_eqn
) should be the name defined for
the quantity (so, in the definition varpars
).
Contains function. These are: - `formula-term` - `formula-eqn-side` - `formula-eqn-side-manifold` ## How to use ### Loading ``` (require '[diman.formula :refer [formula-term formula-eqn-side formula-eqn-side-manifold]]) ``` ### Example Given ``` (def varpars [{:symbol "x", :quantity "length"} {:symbol "v", :quantity "velocity"} {:symbol "t", :quantity "time"} {:symbol "a", :quantity "acceleration"}]) (def lhs "x^(1)") (def rhs {:term1 "x^(1)", :term2 "v^(2)", :term3 "t^(1)", :term4 "0.5*a^(1)*t^(2)"}) (def eqn {:lhs lhs, :rhs rhs}) ``` #### Formula of term To get the formula of a term, say, `(:term4 rhs)` ``` => (formula-term varpars (:term4 rhs)) "[T^(0)*L^(1)]" ``` and for left hand side ``` => (formula-term varpars lhs) "[L^(1)]" ``` #### Formula of a side of the equation For right hand side ``` => (formula-eqn-side varpars rhs) "[L^(1)] + [T^(-2)*L^(2)] + [T^(1)] + [T^(0)*L^(1)]" ``` for left hand side ``` => (formula-eqn-side varpars lhs) "[L^(1)]" ``` #### Evaluating formula for a side for multiple equations Lets say we have two different equations ``` (def p_leftside "p^(1)") (def p_rightside {:term1 "x^(2)*v^(-1)*t^(1)"}) (def p_equation {:lhs p_leftside, :rhs p_rightside}) ``` and ``` (def q_leftside "q^(1)") (def q_rightside {:term1 "x^(1)*a^(6)*t^(20)"}) (def q_equation {:lhs q_leftside, :rhs q_rightside}) ``` The RHS of the above two equations can be evaluated in one step using `formula-eqn-side-manifold`. To do this let us set up its argument ``` (def manifold_eqn [{:name "p_quantity" :eqn (:rhs p_equation)} {:name "q_quantity" :eqn (:rhs q_equation)}]) ``` Now we may invoke the method by passing the above as the argument ``` => (formula-eqn-side-manifold varpars manifold_eqn) [{:quantity "p_quantity", :dimension "[L^(-1)*L^(2)*T^(2)]"} {:quantity "q_quantity", :dimension "[L^(6)*T^(8)*L^(1)]"}] ``` **NOTE:** If the user plans to insert these derived dimensional formulae into the `standard_formula` the name given for respective `:quantity` in the above argument (here we named it `manifold_eqn`) **should be the name defined** for the quantity (so, in the definition `varpars`).
(formula-eqn-side-manifold varpar_def manifold_eqn_side_expr)
(formula-eqn-side-manifold varpars manifold_eqn manifold_formula)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close