Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
visb-visualisation-examples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
visb-visualisation-examples
Commits
1eaf5036
Commit
1eaf5036
authored
4 years ago
by
Michael Leuschel
Browse files
Options
Downloads
Patches
Plain Diff
first working version of physics model
parent
20136c1c
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Physics/MovingParticles.mch
+19
-6
19 additions, 6 deletions
Physics/MovingParticles.mch
Physics/Vectors.mch
+6
-1
6 additions, 1 deletion
Physics/Vectors.mch
Physics/three_bodies.json
+25
-0
25 additions, 0 deletions
Physics/three_bodies.json
Physics/three_bodies.svg
+15
-2
15 additions, 2 deletions
Physics/three_bodies.svg
with
65 additions
and
9 deletions
Physics/MovingParticles.mch
+
19
−
6
View file @
1eaf5036
MACHINE MovingParticles
INCLUDES Vectors
DEFINITIONS
"LibraryReals.def";
"LibraryReals.def";
"SORT.def";
MASS == FLOAT;
POS == FLOAT;
SPEED == FLOAT;
...
...
@@ -10,13 +10,25 @@ DEFINITIONS
SCALE == 1.25e11; // 100 % in visualisation
SCALE100 == (SCALE/100.0);
SPEED_MULTIPLIER == 1000000.0;
MAXMASS == 1.989e30
GRAV_MULTIPLIER == 1000000000000.0;
MAXMASS == 1.989e30;
gravitation == %i.(i:OBJ | sigma_vecs(
SQUASH(
%j.(j:OBJ & j/=i |
times_vec( force_between(i,j,pos(i),pos(j)) / mass(i) ,
unit_vec(delta_vec(pos(j),pos(i)))))
) ) ) // acceleration
ABSTRACT_CONSTANTS
force_between
CONSTANTS mass, nobjs
PROPERTIES
nobjs : 1..10 &
mass : OBJ --> MASS &
force_between = %(a,b,pa,pb).(a:OBJ & b:OBJ & a/=b | (G * mass(a) * mass(b)) / (distance(pa,pb)**2))
&
n = 2 & // two dimensional space
nobjs = 3 & mass = [5.97e24, 1.989e30, 1.989e30]
VARIABLES pos, speed
...
...
@@ -27,9 +39,10 @@ INITIALISATION pos := [ [0.0,0.0] , [0.0,4.5e10] , [0.0,-4.5e10 ] ] ||
speed := [ [0.05e04,0.0], [3.0e04,0.0], [-3.0e04,0.0] ]
OPERATIONS
r <-- ForceBetween(a,b) = PRE a:OBJ & b:OBJ & a/= b THEN
r :=
(G * mass(a) * mass(b)) / (distance(
pos(a),pos(b))
**2)
r :=
force_between(a,b,
pos(a),pos(b))
END;
Move(delta) = PRE delta:REAL & delta = 100000.0 THEN
Move(delta) = PRE delta:REAL & delta = 10000.0 THEN
speed := %i.(i:OBJ | add_vec(speed(i),times_vec(delta,gravitation(i)) )) ||
pos := %i.(i:OBJ | add_vec(pos(i),times_vec(delta,speed(i))) )
END
END
...
...
This diff is collapsed.
Click to expand it.
Physics/Vectors.mch
+
6
−
1
View file @
1eaf5036
...
...
@@ -13,7 +13,9 @@ ABSTRACT_CONSTANTS
distance,
add_first,
sigma_reals
sigma_reals,
add_firstv,
sigma_vecs
PROPERTIES
n:NATURAL1 &
DIM = (1..n) &
...
...
@@ -22,6 +24,9 @@ PROPERTIES
add_first = %v.(v:seq1(REAL) | (v(1)+v(2)) -> tail(tail(v))) &
sigma_reals = %v.(v:VEC | (iterate(add_first,n-1)(v))(1)) &
add_firstv = %v.(v:seq1(VEC) | add_vec(v(1),v(2)) -> tail(tail(v))) &
sigma_vecs = %v.(v:seq1(VEC) | (iterate(add_firstv,size(v)-1)(v))(1)) &
add_vec = %(v1,v2).(v1:VEC & v2:VEC | %i.(i:DIM| v1(i)+v2(i))) &
delta_vec = %(v1,v2).(v1:VEC & v2:VEC | %i.(i:DIM| v1(i)-v2(i))) &
// dot_product = %(v1,v2).(v1:VEC & v2:VEC | SIGMA(i).(i:DIM| v1(i)*v2(i))) &
...
...
This diff is collapsed.
Click to expand it.
Physics/three_bodies.json
+
25
−
0
View file @
1eaf5036
...
...
@@ -44,6 +44,31 @@
"id"
:
"speed%0"
,
"attr"
:
"y2"
,
"value"
:
"(pos(%0)(2)+ SPEED_MULTIPLIER*speed(%0)(2)) / SCALE100"
},
{
"for"
:
{
"from"
:
1
,
"to"
:
3
},
"id"
:
"gravitation%0"
,
"attr"
:
"x1"
,
"value"
:
"pos(%0)(1) / SCALE100"
},
{
"for"
:
{
"from"
:
1
,
"to"
:
3
},
"id"
:
"gravitation%0"
,
"attr"
:
"y1"
,
"value"
:
"pos(%0)(2) / SCALE100"
},
{
"for"
:
{
"from"
:
1
,
"to"
:
3
},
"id"
:
"gravitation%0"
,
"attr"
:
"x2"
,
"value"
:
"(pos(%0)(1)+ GRAV_MULTIPLIER*gravitation(%0)(1)) / SCALE100"
},
{
"for"
:
{
"from"
:
1
,
"to"
:
3
},
"id"
:
"gravitation%0"
,
"attr"
:
"y2"
,
"value"
:
"(pos(%0)(2)+ GRAV_MULTIPLIER*gravitation(%0)(2)) / SCALE100"
}
],
"events"
:
[
...
...
This diff is collapsed.
Click to expand it.
Physics/three_bodies.svg
+
15
−
2
View file @
1eaf5036
...
...
@@ -14,12 +14,12 @@
<marker
id=
"startarrow"
markerWidth=
"10"
markerHeight=
"7"
refX=
"10"
refY=
"3.5"
orient=
"auto"
>
<polygon
points=
"10 0, 10 7, 0 3.5"
fill=
"
blue
"
/>
<polygon
points=
"10 0, 10 7, 0 3.5"
fill=
"
green
"
/>
</marker>
<marker
id=
"endarrow"
markerWidth=
"10"
markerHeight=
"7"
refX=
"0"
refY=
"3.5"
orient=
"auto"
>
<polygon
points=
"0 0, 10 3.5, 0 7"
fill=
"
blue
"
/>
<polygon
points=
"0 0, 10 3.5, 0 7"
fill=
"
green
"
/>
</marker>
</defs>
...
...
@@ -47,4 +47,17 @@
id =
"speed3"
/>
<line
x1=
"45"
y1=
"15"
x2=
"55"
y2=
"15"
stroke=
"green"
stroke-width=
"0.3"
marker-end=
"url(#endarrow)"
id =
"gravitation1"
/>
<line
x1=
"5"
y1=
"15"
x2=
"0"
y2=
"0"
stroke=
"green"
stroke-width=
"0.3"
marker-end=
"url(#endarrow)"
id =
"gravitation2"
/>
<line
x1=
"35"
y1=
"45"
x2=
"35"
y2=
"55"
stroke=
"green"
stroke-width=
"0.3"
marker-end=
"url(#endarrow)"
id =
"gravitation3"
/>
</svg>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment