--
-- SMN model of a 1D classical particle
-- John Ringland 2005/08/27
--

include SMN.e
include test.e

puts(1,"\n{ time, position, velocity, force }\n")

---------------------------------------------------------
-- create and test a single 1D particle
---------------------------------------------------------
---------------------------------------------------------
global function create_1D_particle(atom dt, atom m, sequence iSV) -- iSV={x,v,F}
    SMElement m0, m1, m12, m13, m23
    SystemMatrix M1
    StateVector V

    m0 = {{fdZero},{fdZero}}
    m1 = {{fdOne},{fdOne}}
    m12 = {{defaultFDV(dt)},{fdOne}}
    m13 = {{defaultFDV(power(dt,2)/(2*m))},{fdOne}}
    m23 = {{defaultFDV(dt/m)},{fdOne}}
    M1 = {{m1,m12,m13},
          {m0,m1,m23},
          {m0,m0,m0}}
          
    V = {{defaultFDV(iSV[1])},{defaultFDV(iSV[2])},{defaultFDV(iSV[3])}}
    return {M1,V}
end function

smModel particle
-- create with initial impulse force i.e. {x,v,F} = {0,0,10}
puts(1,"\ncreate with initial impulse force i.e. {x,v,F} = {0,0,10}\n")
particle = create_1D_particle(.2,3,{0,0,10})
test_FLModel(particle, 20, 1, .2)

www.Anandavala.info