4
$\begingroup$

I have been trying with out success to edit this impact crater simulation script into producing a variable which calculates crater density. In addition I have been trying to figure out how to determine the time when crater saturation is reached. Where crater saturation is defined as the average number of craters in the test area changes by less than 5% when the time is doubled.

This is the code I have been trying to manipulate.

craters = {{0, 0}};
number = {1};
Dynamic[
(craters = #;
Row[{Graphics[{[email protected], Point@#}, ImageSize -> 230,  PlotRange -> 300, Frame -> True], 
  ListLinePlot[AppendTo[number, Length@#], PlotRange -> All, ImageSize -> {Automatic, 210}, 
                                                                        Frame -> True]}]) &@
(Join[{#}, Complement[craters, Nearest[craters, #, {Infinity, 30}]]] &@ RandomReal[{-250, 250}, 2])
]

enter image description here

$\endgroup$
6
  • 1
    $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ Commented Nov 3, 2015 at 6:17
  • $\begingroup$ Just realized sending a personal message isn't a function on this website. Sorry again. Noob user here. $\endgroup$
    – Daniel
    Commented Nov 3, 2015 at 6:58
  • 1
    $\begingroup$ Don't worry too much about it. Each community has its own particular rules and it takes some time to get acquainted. Relax and enjoy. Welcome $\endgroup$ Commented Nov 3, 2015 at 7:01
  • $\begingroup$ FWIW @belisariusisforth's code crashes my kernel (Nearest crashes on the second call ) $\endgroup$
    – george2079
    Commented Nov 3, 2015 at 20:46
  • $\begingroup$ @george2079 V9 gif updated on question $\endgroup$ Commented Nov 3, 2015 at 21:33

1 Answer 1

2
$\begingroup$

Here is an approach to implementing a steady state stop criteria by performing a regression on the last n values.

craters = {{0., 0.}}; 
number = {1};
nlast = 500;
tol = 0.001;
Dynamic[(
    craters = #;
    clen = Min[nlast, Length@number];
    fit = 
     LinearModelFit[number[[-clen ;;]], x, x]["BestFitParameters"];
    slope = fit[[2]];
    If[Abs[slope] < tol, FinishDynamic[]];
    Row[{ 
      Graphics[{[email protected], Point@#}, ImageSize -> 230, 
       PlotRange -> 300, Frame -> True], 
      ListLinePlot[AppendTo[number, Length@#], PlotRange -> All, 
       ImageSize -> {Automatic, 210}, Frame -> True, 
       Epilog -> {Text["trend slope = " <> ToString[slope], 
          Scaled[{.8, .5}]], Thick, Red, 
         Line[{{Length@number - clen, fit[[1]]}, {Length@number, 
            fit[[1]] + clen slope }}]}]}]) &@(Join[{#}, 
      Complement[craters, Nearest[craters, #, {Infinity, 30}]]] &@
    RandomReal[{-250, 250}, 2])]

enter image description here

enter image description here

$\endgroup$
1
  • $\begingroup$ This is fantastic thanks a bunch. $\endgroup$
    – Daniel
    Commented Nov 4, 2015 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.