python一对一辅导教程:Computational Problems for Physics chapter 1-A Code Listings 1.1 - 1.6

Computational-physics:计算物理例程 计算物理学 C语言中的计算物理例程 内容 使用梯形规则实现的集成,支持具有自定义参数的功能 立即下载

作者自我介绍:大爽歌, b站小UP主 ,直播编程+红警三 ,python1对1辅导老师 。
本博客为一对一辅导学生python代码的教案, 获得学生允许公开。
具体辅导内容为《Computational Problems for Physics With Guided Solutions Using Python》,第一章(Chapter 1 Computational Basics for Physics)的 Code Listings
由于代码较多,第一章内容分为三部分
A(1.1 - 1.6)
B(1.7 - 1.11)
C(1.12 - 1.17)

0 安装第三方库

已安装
  • numpy
  • matplotlib
待安装
  • vpython
  • pylab (a tool from matplotlib)
  • mpl_toolkits (a tool from matplotlib)
  • visual (unknown)
pip install VPython -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple
参考书(链接):

https://www.glowscript.org/docs/VPythonDocs/graph.html

1 - vpython graph

uses VPython to produce the two plots in Figure 1.1.

  • graph

a graph is inherently 2D and contains graphing objects for displaying curves, dots, and vertical or horizontal bars.
粗略中文理解,一片2D区域,展示graphing objects,像画板一样

如果不设置graph, 代码里面的图会绘制到vpython的默认初始graph(自带的)中
设置了graph后,代码里面的图会绘制到它最近的上面的那个graph中

以下展示了两个graph对象

生成该图的代码如下

from vpython import *  # EasyVisualVP.py


graph1=graph(align='left',width=400,height=400, background=color.white,foreground=color.red)

Plot1=gcurve(color=color.blue)  # gcurve method
for x in arange(0,8.1,0.1):  # xrange
    Plot1.plot(pos=(x,5*cos(2*x)*exp(-0.4*x)))

graph2=graph(align='right',width=400,height=400,
             background=color.yellow,foreground=color.blue,
             title='2-DPlot',xtitle='x',ytitle='f(x)')

Plot2=gdots(color=color.green)  # Dots
for x in arange(-5,5,0.1):
    Plot2.plot(pos=(x,cos(x)))  # plotdots

我们提取出上面代码中,生成两个graph对象的生成代码来观察下

graph1=graph(align='left', width=400, height=400, 
             background=color.white, foreground=color.red)
graph2=graph(align='right',width=400, height=400,
             background=color.yellow, foreground=color.blue,
             title='2-DPlot', xtitle='x', ytitle='f(x)')

graph是一个class, 创建graph对象代码中的参数意思

  • align 对齐方式 只能是以下三个值之一
    'left', 'right', or 'none'(the default).
  • width 宽度
  • height 高度
  • background 背景色
  • foreground 前景色(方框和xy轴的刻度颜色)
  • title 图标题
  • xtitle x轴的标题
  • ytitle y轴的标题

参数拓展(上面只展示了graph刚才用的的参数,graph所有参数如下)

# from vpython.py :2253
scalarAttributes = ['width', 'height', 'title', 'xtitle', 'ytitle','align',
'xmin', 'xmax', 'ymin', 'ymax', 'logx', 'logy', 'fast', 'scroll']

2 - vpython graph plotting objects

  • gcurve: a connected curve 连通的曲线
  • gdots: disconnected dots 散点
  • gvbars: vertical bars 垂直条
  • ghbars: horizontal bars 水平条

使用对应的方法,将会根据设置的样式生成具有该样式的plotting

比如Plot1=gcurve(color=color.blue)就会生成一个颜色为蓝色的连通的曲线gcurve。

这个时候曲线上是没有内容的,即没有点。

比如运行以下两行代码,会生成一个空白页面(因为没有内容)

from vpython import *  # Import Vpython
Plot1=gcurve(color=color.blue)

给这个曲线加点的方法如下(简单写法,这个里面参数可能还有可以拓展说明的,具体后面遇到再说)
Plot1.plot(pos=(x,y))

一般会使用循环来添加,例如for x in arange(start, end, step)。

其中arange, 是来自numpy的函数。

这个函数比range好,因为支持float浮点数(range不支持)。

这里展示下上面四种类型的plotting objects的效果,如下

对应代码为

from vpython import *  # changed from 3GraphVP.py

graph(align='left', title="gcurve show sin(x) ** 2)", xtitle='x', ytitle='y', background=color.white, foreground=color.black)
y1 = gcurve(color=color.blue)
for x in arange(-5, 5, 0.1):
    y1.plot(pos=(x, sin(x) ** 2))

graph(align='left',title="gvbars show cos(x) * cos(x)", xtitle='x', ytitle='y', background=color.white, foreground=color.black)
y2 = gvbars(color=color.yellow)

for x in arange(-5, 5, 0.1):
    y2.plot(pos=(x, cos(x) * cos(x) / 3.))

graph(align='left',title="gdots show sin(x) * cos(x)", xtitle='x', ytitle='y', background=color.white, foreground=color.black)
y3 = gdots(color=color.red)

for x in arange(-5, 5, 0.1):
    y3.plot(pos=(x, sin(x) * cos(x)))

graph(align='left',title="ghbars show sin(x)", xtitle='x', ytitle='y', background=color.white, foreground=color.black)
y4 = ghbars(color=color.green)

for x in arange(-5, 5, 0.1):
    y4.plot(pos=(x, sin(x)))

3 - vpython 中的一些其他常用变量

color

颜色,包含以下几个值
black、white、red、green、blue、
yellow、cyan、magenta、orange、purple

其他包(Package)

vpython里面包含了其他包, 比如numpy,所以上面的代码才可以直接写arange, sin等函数。

这里展示下包含的常用包方法

  • math.*
    包含sin, cos等等
  • numpy.arange
  • random.random

4 - numpy array

The array object in NumPy is called ndarray.

可以用列表创建,也常用np.arange(Xmin, Xmax, DelX)方法来创建

数组很像列表,但比里列表强大,强在支持各种运算
比如下面的

import numpy as np  # a part from EasyMatPlot.py


Xmin = -5.;    Xmax = +5.;    Npoints = 20
DelX = (Xmax - Xmin) / Npoints

x = np.arange(Xmin, Xmax, DelX)
y = np.sin(x) * np.sin(x*x)
print(x)
# [-5.  -4.5 -4.  -3.5 -3.  -2.5 -2.  -1.5 -1.  -0.5  0.   0.5  1.   1.5  
# 2.   2.5  3.   3.5  4.   4.5]
print(y)
# [-0.12691531  0.96338048 -0.21788595 -0.10913545 -0.05815816  0.01985684
#   0.68815856 -0.77612411 -0.70807342 -0.11861178  0.          0.11861178
#   0.70807342  0.77612411 -0.68815856 -0.01985684  0.05815816  0.10913545
#   0.21788595 -0.96338048]

注意:numpy中也有sin、cos方法,
但是和math中的sin、cos方法不同,numpy中的支持数组运算。

pylab 对 numpy 的调用

pylab 中,对numpy进行了两次重要调用如下

from numpy import *
import numpy as np

所以在导入了pylab的代码中,使用np.arange和arange都是可以的。
需要注意的一点事,此时使用sin和cos等,都是来自numpy的支持数组运算的。

5 - 1.3 EasyMatPlot.py

1 占位符

详细文档:python 格式化输出详解 上篇

占位符格式

  • ”%s“ % variable 一个
  • ”%s %s %s“ % (a, b, c) 多个

具体到EasyMatPlot.py的代码中的
”%8.2f“ % x[0]的%8.2f

  • 8是width,占位符总宽度(字符、数字个数)
  • .2 是精度设置,代表精度为2, 可以理解为保留2位小数
  • f 代表格式为浮点数

运行效果如下

y = [196338.048,-0.12691531,-78.8595,-581581.6]
print("%8.2f,%8.2f,%8.2f,%8.2f" % tuple(y))
# 196338.05,   -0.13,  -78.86,-581581.60
2 EasyMatPlot 绘制效果

其代码如下

from pylab import *  # EasyMatPlot.py

Xmin = -5. ;  Xmax = +5. ;  Npoints = 500 
DelX = (Xmax - Xmin) / Npoints

x = arange(Xmin, Xmax, DelX)
y = sin(x) * sin(x*x)

print("arange => x[0], x[1], x[499] = %8.2f %8.2f %8.2f" %(x[0], x[1], x[499]))
print("arange => y[0], y[1], y[499] = %8.2f %8.2f %8.2f" %(y[0], y[1], y[499]))

print("\n Doing plotting, look for Figure 1")

xlabel('x') ;  ylabel('f(x)') ;  title('f(x)vsx')
text(1.75, 0.75, 'MatPlotLib \n Example')
plot(x, y, '-', lw=2)
grid(True)
show()

绘制效果如图

后半部分代码说明见下文(即第六部分)

6 - matplotlib

pylab中导入了 matplotlib 。
EasyMatPlot.py最后五行的代码使用的方法其实都是matplotlib.pyplot的方法
一般matplotlib都会导入pyplot为plt

1 函数简单介绍
  • xlabel 设置x轴文本

  • ylabel 设置y轴文本

  • title 设置图表标题

  • grid 是否展示网格

  • show 展示图表

  • text(x, y, s) 在图上坐标为(x,y)的地方展示文本s。

2 plot

详细文档: matplotlib.pyplot.plot

plot函数比较复杂,其详细参数格式如下

matplotlib.pyplot.plot(*args, scalex=True, scaley=True, data=None, **kwargs)

这里我们做一个简化的介绍,介绍一些常见的写法(可能还会有其他写法,遇到再说)
EasyMatPlot.py中的写法plot(x, y, '-', lw=2),是一种比较常见的写法

plot([x], y, [fmt], *, data=None, **kwargs)
plot([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)

其中

  • x 横坐标组成的列表(或数组),
  • y 纵坐标组成的列表(或数组)
  • fmt 定义基本格式(如颜色、标记和线型),EasyMatPlot.py中的’-'代表线型为实线

fmt 只是快速设置基本属性的缩写。所有这些以及更多的都可以由关键字kwargs参数控制。

fmt 详细格式为[marker][line][color]

说明值举例
marker标记(点的样式)'.'、','、'o'、'v'、'^'、'<'、'>'、'1'、'2'、'3'、'4'
line线的样式'-'、'--'、'-.'、':'
color颜色'r'、'g'、'b'、'c'、'm'、'y'、'k'、'w'

将EasyMatPlot.py中绘图时的fmt设置为'o--r',
效果如下图(标记点为圆点,线为虚线,颜色为color).

marker、line、color都是可选的,都不指定的话使用使用样式循环style cycle中的值
两点说明:
不指定marker的话,不展示点。
指定了marker不指定line的话,不展示线。

这个特性可以用来分别指定线和点。
fmt设置为'^b'

fmt设置为'-.g'

详细参数说明见官方文档
中的fmt部分

  • kwargs 设置一些keyword参数,EasyMatPlot.py中的lw=2代表线宽设置为2,等价于(linewidth=2)
    详细参数说明见官方文档
    中的kwargs部分
3 errorbar

Plot y versus x as lines and/or markers with attached errorbars.
from errorbar

具体效果为,在指定点绘制误差线(x轴或者y轴)

参数过多,简单写法为
matplotlib.pyplot.errorbar(x, y, yerr=None, xerr=None, fmt='', **kwargs)

yerr: 指定平行于y轴的误差线范围(长度)
xerr: 指定平行于x轴的误差线范围(长度)

其值格式相同,支持

  • scalar(a float): 对称加减值
  • shape(N,): 一维数组(N和x,y的N相同),对称加减值
  • shape(2, N): 二维数组(N和x,y的N相同), 分别指定加减值。
    Separate - and + values for each bar. First row contains the lower errors, the second row contains the upper errors.
  • None: No errorbar.
import pylab as p
from numpy import *

x1 = arange(0, 5, 1)                    # Data set 1 points
y1 = array([4.0, 2.7, -1.8, -0.9, 2.6])
errTop = array([1.0, 0.3, 1.2, 0.4, 0.1]) # Asymm errors
errBot = array([2.0, 0.6, 2.3, 1.8, 0.4])
p.errorbar(x1, y1, [errBot, errTop], fmt = 'o') # Error bars

p.show()

效果如下图

7 - 1.4 GradesMatPlot.py

GradesMatPlot一张图里面绘了很多线,多了就乱,乱了就容易分不清哪个图是哪个代码产生的。

所以对代码分段,图分别绘制(中间show一次就是绘制了一次),
即代码如下

import pylab as p                           # Matplotlib
from numpy import *

p.title('Grade Inflation')           # Title and labels
p.xlabel('Years in College')
p.ylabel('GPA')
xa = array([-1, 5])                  # For horizontal line
ya = array([0, 0])
p.plot(xa, ya)                       # Draw horizontal line
p.show()   # draw 1 


x0 = array([0, 1, 2, 3, 4])            # Data set 0 points
y0 = array([-1.4, +1.1, 2.2, 3.3, 4.0])
p.plot(x0, y0, 'bo')            # Data set 0 = blue circles
p.plot(x0, y0, 'g')                     # Data set 0 = line
p.show()  # draw 2 


x1 = arange(0, 5, 1)                    # Data set 1 points
y1 = array([4.0, 2.7, -1.8, -0.9, 2.6])
p.plot(x1, y1, 'r')
errTop = array([1.0, 0.3, 1.2, 0.4, 0.1]) # Asymm errors
errBot = array([2.0, 0.6, 2.3, 1.8, 0.4])
p.errorbar(x1, y1, [errBot, errTop], fmt = 'o') # Error bars
p.grid(True)                                    # Grid line
p.show()  # draw 3

三次绘制效果如下图

GradesMatPlot.py中三图一起绘制,就是叠在一起,如下图

8 - 1.5 MatPlot2figs.py

1 figure

创建一个新的图形(窗口),或者激活一个现有的图形,
返回一个matplotlib.figure.Figure对象,返回值有时会用到。

简单使用方法:

matplotlib.pyplot.figure(num=None)

num: 图形的唯一标识符,可以为数字(int)和字符串(string)。

如果具有该标识符的图形已经存在,则此图形将被激活并返回。
如果没有,就创建一个新的图形(窗口)。

这里举一个代码的例子如下:

from pylab import *  # Simplified from MatPlot2figs.py

Xmin = -5.0;      Xmax =  5.0;        Npoints= 500
DelX= (Xmax-Xmin)/Npoints                             # Delta x
x1 = arange(Xmin, Xmax, DelX)                        # x1 range
y1 = -sin(x1)*cos(x1*x1)                           # Function 1
y2 = exp(-x1/4.)*sin(x1)
y3 = sin(x1) + cos(x1)

figure("one")
plot(x1, y1, 'r', lw=2)

figure("two")
plot(x1, y2, '-', lw=2)

figure("one")
plot(x1, y3, '--', lw=2)

show()

运行后效果如下(会同时打开两个窗口,后面的会挡住前面的,移动一下就好)

补充:
上面代码中的exp函数是numpy中的,
np.exp(x)代表计算e的x次方,
如果x是数组,则针对数组中的元素计算,生成新的数组。

2 subplot

作用: 在当前图形figure上添加一个子图(划分出一个区域绘制子图)。
简单使用方法为subplot(nrows, ncols, index, **kwargs)

将figure划分为nrows行、ncols列个子图区域(此时每个区域内什么都没有),
在第index个区域创建子图并进行绘制(此时会在子图内绘制出初始坐标轴)。

index计算顺序为:从左到右,从上到下。

简单例子如下

from pylab import *

figure(1)
subplot(3,2,2)
show()

绘制效果图如下

3 MatPlot2figs 绘制效果

此时再看MatPlot2figs.py, 就很好看明白了。

from pylab import *      # MatPlot2figs.py

Xmin = -5.0;      Xmax =  5.0;        Npoints= 500
DelX= (Xmax-Xmin)/Npoints                             # Delta x
x1 = arange(Xmin, Xmax, DelX)                        # x1 range
x2 = arange(Xmin, Xmax, DelX/20)            # Different x2 range
y1 =  -sin(x1)*cos(x1*x1)                           # Function 1
y2 =   exp(-x2/4.)*sin(x2)                          # Function 2
print("\n Now plotting, look for Figures 1 & 2 on desktop")

figure(1)
subplot(2,1,1)                     # 1st subplot in first figure
plot(x1, y1, 'r', lw=2) 
xlabel('x');      ylabel( 'f(x)' ); title( '-sin(x)*cos(x^2)' )
grid(True)                                         # Form grid
subplot(2,1,2)                     # 2nd subplot in first figure
plot(x2, y2, '-', lw=2)
xlabel('x')                                        # Axes labels
ylabel( 'f(x)' )
title( 'exp(-x/4)*sin(x)' )

#                                  Figure 2 
figure(2)
subplot(2,1,1)                     # 1st subplot in 2nd figure
plot(x1, y1*y1, 'r', lw=2) 
xlabel('x'); ylabel('f(x)'); title('sin^2(x)*cos^2(x^2)') # grid
subplot(2,1,2)                       # 2nd subplot in 2nd figure
plot(x2, y2*y2, '-', lw=2)
xlabel('x');   ylabel( 'f(x)' );  title( 'exp(-x/2)*sin^2(x)' ) 
grid(True)
show()                                           # Show graphs

其绘制效果如图

9 - 1.6 Simple3Dplot.py

1 meshgrid

meshgrid是numpy中的方法,用于从坐标向量(一维)返回坐标矩阵(多维)。
简单写法为np.meshgrid(*xi)

*xi:*代表可以接受不定数量个参数,每个参数为表示网格坐标的一维数组。

x1, x2,…, xn array_like.
1-D arrays representing the coordinates of a grid.

代码示例

import numpy as np

delta = 0.5
x = np.arange( -2., 2., delta )
y = np.arange( -1., 1., delta )
X, Y = np.meshgrid(x, y)
Z = np.sin(X) * np.cos(Y)
print(X)
# [[-2.  -1.5 -1.  -0.5  0.   0.5  1.   1.5]
#  [-2.  -1.5 -1.  -0.5  0.   0.5  1.   1.5]
#  [-2.  -1.5 -1.  -0.5  0.   0.5  1.   1.5]
#  [-2.  -1.5 -1.  -0.5  0.   0.5  1.   1.5]]
print(Y)
# [[-1.  -1.  -1.  -1.  -1.  -1.  -1.  -1. ]
#  [-0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5]
#  [ 0.   0.   0.   0.   0.   0.   0.   0. ]
#  [ 0.5  0.5  0.5  0.5  0.5  0.5  0.5  0.5]]
print(Z)
# [[-0.4912955  -0.53894884 -0.45464871 -0.25903472  0.          0.25903472  0.45464871  0.53894884]
#  [-0.79798357 -0.87538421 -0.73846026 -0.42073549  0.          0.42073549  0.73846026  0.87538421]
#  [-0.90929743 -0.99749499 -0.84147098 -0.47942554  0.          0.47942554  0.84147098  0.99749499]
#  [-0.79798357 -0.87538421 -0.73846026 -0.42073549  0.          0.42073549  0.73846026  0.87538421]]

直播间某位会matlab的观众弹幕补充(是否适用于matplotlib待确定):
要绘制3d网格的话要3点坐标,必须使用2d网格。
如果只是绘制3D线条就不用了(不需要使用meshgrid)

2 Axes3D

mpl_toolkits.mplot3d.axes3d.Axes3D(fig, **kwargs)

绘制三维坐标轴,返回一个坐标轴对象。

Simple3Dplot.py中,该对象用到的方法:

  • plot_surface(X, Y, Z) 绘制曲面
  • plot_wireframe(X, Y, Z, color = 'r') 绘制3D线框

上面两个方法X, Y, Z都必须是2D array。

两个方法效果分别如下图
(左边是plot_surface绘制曲面,右边是plot_wireframe绘制线框)

  • set_xlabel(xlabel)
  • set_ylabel(ylabel)
  • set_zlabel(zlabel)

分别设置x,y,z轴的标签

3 Simple3Dplot 绘制效果
import matplotlib.pylab  as p  # Simple3Dplot.py                                   
from mpl_toolkits.mplot3d import Axes3D

print("Please be patient while I do importing & plotting")
delta = 0.1
x = p.arange( -3., 3., delta )
y = p.arange( -3., 3., delta )
X, Y = p.meshgrid(x, y)
Z = p.sin(X) * p.cos(Y)                       # Surface height


fig = p.figure()                               # Create figure
ax = Axes3D(fig)                                  # Plots axes
ax.plot_surface(X, Y, Z)                            # Surface
ax.plot_wireframe(X, Y, Z, color = 'r')        # Add wireframe
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
p.show()                                        # Output figure

绘制效果如图

Problem Solving with Python 3.6 Edition By 作者: Peter Kazarinoff Pub Date: 2019 ISBN: n/a Pages: 326 Language: English Format: PDF Size: 10 Mb Get started solving problems with the Python programming language!This book introduces some of the most famous scientific libraries for Python:Python’s math and statistics module to do calculationsMatplotlib to build 2D and 3D plotsNumPy to complete calculations on arraysJupiter Notebooks to share results with a teamSymPy to solve equationsPySerial to control an Arduino with PythonMicroPython to control an LEDThis book is great for budding engineers and data scientists. The text starts with the basics but finishes with topics rarely included in other engineering and data science programming books like SymPy and PySerial and MicroPython. 立即下载

相关推荐

Problem Solving with Python 3.6 Edition+高清无码无水印+目录附录完整+文字可编辑复制

Overview: You will find the book chapters on the left hand menu You will find navigation within a section of a chapter (one webpage) on the righthand menu Full documentation on how to build this site locally are on GitHub at github.com/professorkazarinoff/Problem-Solving-with-Python/website Motivation: The motivation for writing this book is that many undergraduate engineering students have to take a programming course based on MATLAB. MATLAB is a great piece of software, but it currently costs $49.00 for a student license and requires a site license to be used on school computers. Subsequently, it is costly for a student to use MATLAB and it is costly for a college to support a course that uses MATLAB. In addition, this site license expires eventually and students need to purchase another copy often before they finish their degree. The Python programming language, on the other hand, is open source and free. To download and use Python, the cost to both the student and the college is zero (minus time spent). By moving an undergraduate engineering programming class to Python, students will save money and have greater access to the software they use in class. Further in their engineering education, students can continue to use Python for free. 全书共计13章,326页,专注于解决使用Python过程中常见的各种问题,既包括Python本身的问题,也包括常用的各种工具箱的使用问题,非常实用,强烈推荐!

python一对一辅导教程:Computational Problems for Physics chapter 1-B Code Listings 1.7 - 1.11

作者自我介绍:大爽歌, b站小UP主 ,直播编程+红警三 ,python1对1辅导老师 。 本博客为一对一辅导学生python代码的教案, 获得学生允许公开。 具体辅导内容为《Computational Problems for Physics With Guided Solutions Using Python》,第一章(Chapter 1 Computational Basics for Physics)的 Code Listings 由于代码较多,第一章内容分为三部分 A(1.1 - 1.6) B(.

大爽老师的博客 601

产业园区如何高效对接企业技术需求与高校科研成果?.docx

科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。

【索引】Chapter 1. Algorithm Design_General Problem Solving Techniques_Examples

链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456 Root :: AOAPC I: Beginning Algorithm Contests -- Training Guide (Rujia Liu) :: Chapter 1. Algorithm Design

Remilia's 1154

国央企创新负责人如何快速掌握本地科技资源分布与匹配情况?.docx

科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。

05、基于ALV表报实现复选框、全选、取消全选等功能

基于Function ALV实现复选框、全选及取消全选等功能

wo520yl1314的博客 2372

python代码物理_觉得物理太难了?用Python和Matplotlib进行模拟

全文共4206字,预计学习时长8分钟觉得物理太难了?本文将模拟N维空间中的某些向量场(例如电磁场),以便你更清晰地理解这些概念。理论基础向量任何物理场景的基本元素都是向量。我们需要什么?需要向量的算术运算、距离、模块以及一些技术层面的东西。从列表中得到向量。下面是它初始化的样子:class Vector(list): def __init__(self, *el): for e in el: se...

weixin_39975868的博客 604

ControlRig蓝图节点对应代码(自用)

用于通过python生成ControlRig蓝图节点,非完整

dicha9的博客 426

Python 物理引擎pymunk最完整教程(下)

身体、形状、以及约束对象都要被添加到空间中才能起作用。添加的方法是Space.add方法。有一些功能只有在物体被加入空间后才能使用,例如查询。

pythonzzy的博客 2428

告别手动解析!用这个Qt库轻松处理Cat 21/62等18种Asterix航空数据

本文介绍了基于Qt框架的高效Asterix报文解析库,帮助开发者轻松处理Cat 21/62等18种航空数据。该库通过协议抽象化、多维度API设计和跨平台支持,解决了手动解析的复杂性和易错问题,显著提升开发效率和系统可靠性。

weixin_42529366的博客 207

【GPT】Coze使用开放平台接口-【7】Dify 比较篇

coze 用于社交,dify 用来内部构建。抛开工作流,机器人,工具,coze 最大的区别在于可以直接发布到社交媒体上。所以,coze 对操作体验上也花了不少功夫,而 dify 就专注在帮助使用者打磨工作流。coze 各个大模块之前可以联动的机制也比较多,所以侧重点各不相同。

非晓为骁的博客 7613

python一对一辅导教程:Computational Problems for Physics chapter 1-C Code Listings 1.12 - 1.17

作者自我介绍:大爽歌, b站小UP主 ,直播编程+红警三 ,python1对1辅导老师 。 本博客为一对一辅导学生python代码的教案, 获得学生允许公开。 具体辅导内容为《Computational Problems for Physics With Guided Solutions Using Python》,第一章(Chapter 1 Computational Basics for Physics)的 Code Listings 由于代码较多,第一章内容分为三部分 A(1.1 - 1.6) B(.

大爽老师的博客 521

数字IC面试核心:从MUX基础到Glitch-Free时钟切换电路深度剖析

本文深入剖析数字IC设计中的MUX基础原理及其在Glitch-Free时钟切换电路中的应用。从二选一MUX的门级实现到时钟切换中的毛刺问题,详细讲解了同步切换机制和工程优化技巧,帮助工程师掌握高速时钟电路设计的核心要点。

weixin_42629815的博客 325

python代码物理_利用python求解物理学中的双弹簧质能系统详解

前言本文主要给大家介绍了关于利用python求解物理学中双弹簧质能系统的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧。物理的模型如下:在这个系统里有两个物体,它们的质量分别是m1和m2,被两个弹簧连接在一起,伸缩系统为k1和k2,左端固定。假定没有外力时,两个弹簧的长度为L1和L2。由于两物体有重力,那么在平面上形成摩擦力,那么摩擦系数分别为b1和b2。所以可以把微分方...

weixin_39648430的博客 448

基于微信小程序的答题系统

学习视频:《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!5812)]《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

2401_83330193的博客 499

基于Simulink的电动汽车电池管理系统热管理优化仿真

电动汽车电池管理系统(Battery Management System, BMS)中的热管理是确保电池性能、安全性和寿命的关键环节。温度过高或过低都会显著影响电池的工作效率和寿命,因此需要对电池组进行精确的热管理。基于MATLAB/Simulink的仿真平台可以用于建模和优化电池热管理系统,包括热分布预测、冷却策略设计以及热平衡控制等。本项目旨在构建一个完整的电动汽车电池热管理优化仿真模型,并通过仿真验证系统的性能。

xiaoheshang_123的博客 462

python 物理引擎 摩擦力_Python物理引擎

Python的强大源自众多领域大牛的支持,例如物理引擎方面,就有N多模块支持PyODEPyODE is a set of open-source Python bindings for The Open Dynamics Engine, an open-source physics engine.PyMunkpymunk is a easy-to-use pythonic 2d physics l...

weixin_32955259的博客 992

手把手教你学 MATLAB 实战训练(6.9):卷积神经网络(CNN)模型来进行图像分类任务(预训练的 ResNet-50 模型)

加载数据集数据预处理加载预训练模型修改和扩展预训练模型设置训练选项训练模型测试模型。

xiaoheshang_123的博客 646

化学人学python有前途吗-转载:python之蟒开启理论计算化学的新时代

转载:python之蟒开启理论计算化学的新时代(2014-01-23 23:04:00)标签:pythongaussianpython之蟒开启理论计算化学的新时代就像iphone和android开创了手机的新时代,python也将开启理论化学的新时代。首先谈一下个人的理论化学经历。由于本人是在一个实验为主的小组做计算,所做的课题又多次更换,所以学的软件用的方法都比较杂。在使用各种软件的过程中发现,...

q6q6q的专栏 776

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

Photoshop + Python problem

Photoshop + Python problem  Photoshop + Python problem Tweet  So decided to try and apply what I learned in python thanks to Jason Parks awesome webinar and just wanted to try my ha

chaimyu的专栏 1046

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

下载电子书Problem Solving with Algorithms and Data Structures using Python

哥哥的拥有欲望很强烈,看到书就想下载,手里痒痒就拿网络爬虫来练手。 1、下面是源代码,刚下载两页就老提示断网: Exit with code 1 due to network error: HostNotFoundError 等哥的USB3.0外置网卡回来,用有线网下载,单位的WIFI太差劲了。 2、下载的网页是全部保存,没有除去周围乱七八糟的,这个还得改进。 #!/usr/bi

kaihuangzheng0050的博客 4277

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

04-输出保留3位小数的浮点数「C++信息奥赛题解」

你好,我是悦创。 描述 读入一个单精度浮点数,保留 3 位小数输出这个浮点数。 输入 只有一行,一个单精度浮点数。 输出 也只有一行,读入的单精度浮点数。 样例输入 12.34521 样例输出 12.345 代码 #include <iostream> #include <iomanip> using namespace std; int main() { float f; cin >> f; cout << fixed <&

AI悦创·编程私教1v1 4608

Python私教/Java私教「一对一教学」

计算机行业10年经,不同于千篇一律的教育机构,我的教育模式直面新人成长学习痛点,采用师徒模式,在课程讲授过程中,我会亲自一对一帮扶讲解,把我多年积累的经验和良好的代码素养传递给新人,对新人的成长速度提高是很快的,对于优秀的学生,我也会利用我的人脉积极帮推荐工作。根据学员个人基础定制课程体系,最高效率学习,少走弯路!

AI悦创·编程私教1v1 864
上一篇: pygame 入门实例教程 1 - 复古方块赛车游戏
下一篇: python一对一辅导教程:Computational Problems for Physics chapter 1-C Code Listings 1.12 - 1.17
大爽歌
博客等级 码龄9年 422粉丝 92原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值