Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/lijieumn/argus-distribution
02 July 2024, 10:46:16 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    No releases to show
  • b163a44
  • /
  • figures
  • /
  • fig_5.py
Raw File Download Save again
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:fed4bcf82ac29ac8cae5c4bdf46437273084b424
origin badgedirectory badge
swh:1:dir:6ccf19a211540d7e9aa93c88cc1e6f604fe57355
origin badgerevision badge
swh:1:rev:866bd38a0b1caa7560e66ecae5e19b65b49558a5
origin badgesnapshot badge
swh:1:snp:1829571332419ea704f2da46799cce2de3d5f081

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: 866bd38a0b1caa7560e66ecae5e19b65b49558a5 authored by Jie Li on 04 August 2019, 17:48:21 UTC
Merge pull request #4 from AymericFerreira/master
Tip revision: 866bd38
fig_5.py
import os
import subprocess
import math

python_path = os.path.dirname(os.path.realpath(__file__))
working_dir = os.path.dirname(python_path)

data_dir = 'output/figures/fig_5'
simulated_data_file = 'mass_center_simulated.txt'
analytical_data_file = 'mass_center_analytical.txt'

simulated_file_path = os.path.join(data_dir, simulated_data_file)
os.chdir(working_dir)
if not os.path.exists(data_dir):
	os.makedirs(data_dir)

of = open(simulated_file_path, 'w')
of.write('t\tv\th\n')
of.close()

subprocess.call(['build/apps/argus-cloth', 'simulateoffline', 'conf/inclined_plane.json'])

def dot(a, b):
	return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]

def multiply(v, e):
	return [v[0]*e, v[1]*e, v[2]*e]

def add(a, b):
	return [a[0] + b[0], a[1] + b[1], a[2] + b[2]]

def minus(a, b):
	return [a[0] - b[0], a[1] - b[1], a[2] - b[2]]

def norm(v):
	return math.sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2])

dh = [0, 0, -0.521562]; # Height (vertical distance) between the cloth and the plane.
g = [0, 0, -9.8];	# Gravity acceleration

v0 = [0, 0, -0.2];	# The initial velocity
h0 = -0.2108	# The initial height
# Compute the time when the cloth hits the inclined plane (t_hit = 0.3065)
t_hit = -(math.sqrt(dot(v0, v0) + 2*dot(g, dh)) + v0[2])/g[2]

n = [0.422592, 0.0010409, 0.906319]	# Normal direction of the plane (unit vector).
vertical = [0, 0, 1]	#vertical direction
mu = 0.2 # The friction coefficient
g_n = multiply(n, dot(g, n)) # The component of g in the normal direction.
g_t = minus(g, g_n)	# The component of g in the tangential plane.
f = multiply(g_t, (norm(g_t) - mu*norm(g_n))/norm(g_t)) # The net acceleration (g_t - acceleration by friction).

# The velocity when the cloth hit the plane. v_hit = v0 + g*t_hit
v_hit = add(v0, multiply(g, t_hit))
# The component of the velocity in the normal direction. Projection of v_hit to n.
v_n = multiply(n, dot(v_hit, n))
# The component of the velocity in the plane.
v_t = minus(v_hit, v_n)
# The proportion of velocity in the plane remaining after the hit
v_t_remaining = (norm(v_t) - mu*norm(v_n))/norm(v_t)
# The actual velocity in the plane after the hit
v_t_new = multiply(v_t, v_t_remaining)

fv = multiply(vertical, dot(f, vertical))	# Net acceleration in the vertical direction (after the hit)
vv = multiply(vertical, dot(v_t_new, vertical))	# Velocity in the vertical direction (after the hit)

analytical_file_path = os.path.join(data_dir, analytical_data_file)
of = open(analytical_file_path, 'w')
of.write('t\tv\th\n')

t = 0.0
while t <= 1.0:
	if t <= t_hit: # Before hitting the plane, the motion is free fall.
		v = add(v0, multiply(g, t))	# v = v0 + g*t
		dis = add(multiply(v0, t), multiply(g, 0.5*t*t)) # dis = v0*t + .5*g*t^2
		h = h0 + dis[2]
	else:
		# Time elapsed after the hit
		tnew = t - t_hit
		v = add(v_t_new, multiply(f, tnew)) # v = v_t_new + f*tnew
		dis = add(multiply(vv, tnew), multiply(fv, 0.5*tnew*tnew)) # dis = vv*tnew + 0.5*fv*tnew^2
		h = h0 + dh[2] + dis[2]

	print('{}\t{}'.format(norm(v), h))
	of.write('{}\t{}\t{}\n'.format(t, norm(v), h))
	t += 1e-3

of.close()


subprocess.call(['pdflatex', 'figures/fig_5.tex'])

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API