 soliton = (A, x1) ->
     3*A.pow(2) * (sech(.5*A*(x+x1))).pow(2)
     
-# Soliton graph (LineChart imported from another blab - see "Ext" section)
 lineChart = new $blab.LineChart
     id: "solitons"
     xLabel: "x"


# Animated soliton plot
animateSolitons = (u) ->
    # Solve PDE and plot results.
    # u: initial conditions
    v = fft u
    snapshot = ->
        {u, v} = computeUV(v)
        lineChart.plot(x, u)
    $blab.animate snapshot, 1000, 10
    
# Run: two solitons
initSoliton(-1, 800)
initSoliton(0, 200)  #;

#!end (coffee)


    yTicks: 5
    click: (x, y) -> initSoliton(x, y) 

@kdv = new $blab.BasicAnimation
    numSnapshots: 2000
    delay: 10
    strobeInterval: 10000
    snapshotFunction: ->
    strobeFunction: ->

# Plot control
count = 0 # number of solitons in plot
u0 = null # initial condition
initSoliton = (xS, yS) ->
    @kdv.stopAnimation()
    count++
    if count is 1
        u0 = zeros(x)
        @kdv.n = 0
    x1 = -xS
    A = sqrt(yS/3)
    u0 += soliton(A, x1)
