[Elementary Mechanics-01]Two masses and a spring
[Elementary Mechanics Using Python-01]
Question
5.28 Two masses and a spring. Two particles of m = 0.1 kg are attached with a spring with spring constant k = 100 N/m and equilibrium length b = 0.01 m. Both particles start at rest and the spring is at equilibrium. An external force F = 1000 N acts during 1 s on one of the particles in the direction of the other particle. Find the position of both particles as a function of time from the time t = 0 s when the external force starts acting. (You may solve this problem analytically or numerically).
设置变量
设前后两个质点的位移分别为\(x_1\),\(x_2\),时间为\(t_1\)。
列出质点的微分方程
\begin{matrix}
m\frac{d^2}{dt^2}x_1 = F -k(x_1 - x_2 + b) \\
m\frac{d^2}{dt^w}x_2 = k(x_1 - x_2 + b)
\end{matrix}
\right.
\]
初始值
\begin{matrix}
x_1(0) = 0 \\
x_2(0) = b \\
v_1(0) = 0 \\
v_2(0) = 0 \\
a_1(0) = \frac{F}{m} \\
a_2(0) = 0
\end{matrix}
\right.
\]
利用Python
// 引入库
import numpy as np
import matplotlib.pyplot as plt
// 定义常量
F = 1000
m = 0.1
k = 100
b = 0.01
// 建立时间Array
t = np.linspace(0, 1, 1000000)
// 设置时间间隔
dt = 1/1000000
// 两质点的运动量Array
x1 = np.zeros(1000000, dtype =float)
v1 = np.zeros(1000000, dtype =float)
a1 = np.zeros(1000000, dtype =float)
x2 = np.zeros(1000000, dtype =float)
v2 = np.zeros(1000000, dtype =float)
a2 = np.zeros(1000000, dtype =float)
// 初值条件
x1[0], v1[0], a1[0] = 0, 0, F/m
x2[0], v2[0], a2[0] = b, 0, 0
// 数值积分
for index in range(1, 1000000):
// 质点1的微分方程
a1[index] = (F - k*(x1[index-1] - x2[index-1] + b)) / m
v1[index] = v1[index-1] + a1[index-1]*dt
x1[index] = x1[index-1] + v1[index-1]*dt
// 质点2的微分方程
a2[index] = k*(x1[index-1] - x2[index-1] + b) / m
v2[index] = v2[index-1] + a2[index-1]*dt
x2[index] = x2[index-1] + v2[index-1]*dt
// 弹性碰撞
if x1[index] >= x2[index]:
v1[index], v2[index] = v2[index], v1[index]
// 画图
plt.title("b = {}".format(b))
ax = plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
plt.xlim([0, 1*1.1])
plt.xlabel("t(s)")
plt.ylim([0, 2500*1.1])
plt.ylabel("x(m)")
plt.plot(t, x1, label="x1(t)")
plt.plot(t, x2, label="x2(t)")
plt.legend()
plt.savefig("{0}.jpg".format(b))
我们看看随着b减小二者的运动变化




结论
显然b足够小,我们可以直接忽略弹簧和简谐运动带来的影响,因此有
\left\{
\begin{matrix}
\frac{1}{2}\frac{F}{2m}t^2, 0 \leqslant t \leqslant 1s \\
\frac{1}{2}\frac{F}{2m}t_0^2 + \frac{F}{2m}t_0t, t \geqslant 1s
\end{matrix}
\right.
\]
[Elementary Mechanics-01]Two masses and a spring的更多相关文章
- 01 json环境搭建【spring + pringMVC】
1 导包 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.o ...
- Spring基础01——在IDEA中编写spring.xml
如果需要在IDEA自动创建spring.xml配置文件,那么我们就需要先引入Spring相关的依赖 <dependency> <groupId>org.springframew ...
- 【一头扎进Spring】 01 | 从 HelloWorld 开始看Spring
Spring 是一个开源框架. Spring 为简化企业级应用开发而生. 使用 Spring 可以使简单的 JavaBean 实现以前只有 EJB 才能实现的功能. Spring 是一个 IOC(DI ...
- [Elementary Mechanics Using Python-02]Feather in tornado
Problem 9.17 Feather in tornado. In this project you will learn to use Newton's laws and the force m ...
- spring security 5 There is no PasswordEncoder mapped for the id "null" 错误
转载请注明出处 http://www.cnblogs.com/majianming/p/7923604.html 最近在学习spring security,但是在设置客户端密码时,一直出现了一下错误提 ...
- .NET程序员如何快入门Spring Boot
本篇文章将教你作为一个.NET程序员如何快入门Spring Boot.你不需要用Eclipse,也不需要用IDEA.已经习惯了VS,其他的IDE-- 但不得不说VS Code很厉害,一用就喜欢.微软给 ...
- 再见 Spring Boot 1.X ,Spring Boot 2.X 走向舞台中心
2019年8月6日,Spring 官方在其博客宣布,Spring Boot 1.x 停止维护,Spring Boot 1.x 生命周期正式结束. 其实早在2018年7月30号,Spring 官方就已经 ...
- spring aop 的一个思考
问题: spring aop 默认使用jdk代理织入. 也就是我们常这样配置:<aop:aspectj-autoproxy /> 通过aop命名空间的<aop:aspectj-au ...
- Spring Cloud Eureka 分布式开发之服务注册中心、负载均衡、声明式服务调用实现
介绍 本示例主要介绍 Spring Cloud 系列中的 Eureka,使你能快速上手负载均衡.声明式服务.服务注册中心等 Eureka Server Eureka 是 Netflix 的子模块,它是 ...
随机推荐
- P1541 乌龟棋(DP)
题目背景 小明过生日的时候,爸爸送给他一副乌龟棋当作礼物. 题目描述 乌龟棋的棋盘是一行NNN个格子,每个格子上一个分数(非负整数).棋盘第1格是唯一的起点,第NNN格是终点,游戏要求玩家控制一个乌龟 ...
- codeforces251A. Points on Line
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. N ...
- Springboot 过滤器和拦截器详解及使用场景
一.过滤器和拦截器的区别 1.过滤器和拦截器触发时机不一样,过滤器是在请求进入容器后,但请求进入servlet之前进行预处理的.请求结束返回也是,是在servlet处理完后,返回给前端之前. 2.拦截 ...
- jmespath(2)投影Projections
投影 投影是JMESPath的关键特性之一.它允许您将表达式应用于元素集合.有五种投影: 列表投影 切片投影 对象投影 展平投影 过滤投影 处理投影需要注意的点 投影评估分为两个步骤.左侧(LHS)创 ...
- Mac下anaconda的安装和基本使用
Mac下anaconda的安装和基本使用 安装 在conda官网下载安装conda. 打开terminal输入conda -V,回车显示conda的版本说明安装成功. 将conda更新到最新版本 co ...
- BKDR字符串哈希
BKDR字符串哈希 bkdrhash冲突的可能性非常小,但是由于\(hash\)值非常大不能映射到哈希数组地址上,所以可以通过取余,用余数作为索引地址.但这样做造成了可能的地址冲突. #include ...
- ASP.Net Core 5.0 MVC中AOP思想的体现(五种过滤器)并结合项目案例说明过滤器的用法
执行顺序 使用方法,首先实现各自的接口,override里面的方法, 然后在startup 类的 ConfigureServices 方法,注册它们. 下面我将代码贴出来,照着模仿就可以了 IActi ...
- 忘记Mysql的root用户密码处理方法(以mysql 5.5.33为例)
1.修改mysql服务器的脚本 ~]#vi /etc/rc.d/init.d/mysqld #找到$bindir/mysqld_safe --datadir="$datadir" ...
- 【python接口自动化】- PyMySQL数据连接
什么是 PyMySQL? PyMySQL是在Python3.x版本中用于连接MySQL服务器的一个库,Python2中则使用mysqldb.它是一个遵循 Python数据库APIv2.0规范, ...
- React PureComponent All In One
React PureComponent All In One import React, { // useState, // useEffect, // Component, PureComponen ...