<commit_before>###
  simulator.coffee

  a demo webworker for two-body simulation:
###
define [
    'exports',
    'cs!/wahlque/ode/euler',
    'cs!/wahlque/nbody/bodies3pr',
    'cs!/wahlque/units/au'
], (exports, solver, b3, au) ->
    handle = 0
    time = 0
    start = (e) ->
        [m1, m2, x1, y1, vx1, vy1, x2, y2, vx2, vy2, x3, y3, vx3, vy3] = e.data
        derivative = b3.derivative(au, m1, m2)
        step = solver.solve(derivative)
        phase = [x1, y1, vx1, vy1, x2, y2, vx2, vy2, x3, y3, vx3, vy3]
        evolve = ->
            [time, phase] = step(time, phase, 1)
            self.postMessage({msg: phase.join(', ')})
            self.postMessage(phase)
        handle = setInterval(evolve, 100)

    self.onmessage = (e) ->
        if handle
            clearInterval(handle)
        start(e)
        true

    exports
<commit_msg>change from euler to verlet<commit_after>###
  simulator.coffee

  a demo webworker for two-body simulation:
###
define [
    'exports',
    'cs!/wahlque/ode/verlet',
    'cs!/wahlque/nbody/bodies3pr',
    'cs!/wahlque/units/au'
], (exports, solver, b3, au) ->
    handle = 0
    time = 0
    start = (e) ->
        [m1, m2, x1, y1, vx1, vy1, x2, y2, vx2, vy2, x3, y3, vx3, vy3] = e.data
        acceleration = b3.acceleration(au, m1, m2)
        step = solver.solve(acceleration)
        x = [x1, y1, x2, y2, x3, y3]
        v = [vx1, vy1, vx2, vy2, vx3, vy3]
        evolve = ->
            [time, x, v] = step(time, x, v, 1)
            [x1, y1, x2, y2, x3, y3] = x
            [vx1, vy1, vx2, vy2, vx3, vy3] = v
            phase = [x1, y1, vx1, vy1, x2, y2, vx2, vy2, x3, y3, vx3, vy3]
            self.postMessage({msg: phase.join(', ')})
            self.postMessage(phase)
        handle = setInterval(evolve, 100)

    self.onmessage = (e) ->
        if handle
            clearInterval(handle)
        start(e)
        true

    exports

{'fraction_non_alphanumeric': 0.1576458223857068, 'fraction_numerical': 0.051497635312664214, 'mean_word_length': 1.951937984496124, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4733993', 'n_tokens_mistral': 808, 'n_tokens_neox': 774, 'n_words': 188}