當前位置: 首頁>>代碼示例>>Python>>正文


Python Problem.set_initial_condition方法代碼示例

本文整理匯總了Python中Problem.Problem.set_initial_condition方法的典型用法代碼示例。如果您正苦於以下問題:Python Problem.set_initial_condition方法的具體用法?Python Problem.set_initial_condition怎麽用?Python Problem.set_initial_condition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Problem.Problem的用法示例。


在下文中一共展示了Problem.set_initial_condition方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: init

# 需要導入模塊: from Problem import Problem [as 別名]
# 或者: from Problem.Problem import set_initial_condition [as 別名]
def init(v0, T, dt, N, parameters):
	problem = Problem(parameters)
	problem.set_initial_condition(v0);

	c = Solver(problem)
	c.set_timestep(dt)
	v = c.solve(T)

	time = linspace(0,dt*N,N);
	return time, v
開發者ID:torbjornseland,項目名稱:INF5620,代碼行數:12,代碼來源:vertical_motion.py

示例2: int

# 需要導入模塊: from Problem import Problem [as 別名]
# 或者: from Problem.Problem import set_initial_condition [as 別名]
from Problem import Problem
from solver_vertical_motion import Solver
from read_file import read_file
from scitools.std import plot
from numpy import linspace, array, zeros
import sys

v0 = 0
T = 100
dt = 0.01
N = int(T/float(dt))

parameters = read_file(sys.argv[1:])
problem = Problem(parameters)
problem.set_initial_condition(v0);

c = Solver(problem)
c.set_timestep(dt)
v = c.solve(T)

v = array(v)
F_d = zeros(N)
for i in range(N):
        F_d[i] = problem.get_drag_force(v[i])

F_g = zeros(N) + problem.get_gravity_force()
F_b = zeros(N) + problem.get_buoyancy_force()

time = linspace(0,dt*N,N);

plot(time,F_d,time,F_g,time,F_b, legend=['drag','gravity','buoyancy'])
開發者ID:torbjornseland,項目名稱:INF5620,代碼行數:33,代碼來源:vertical_motion_force.py


注:本文中的Problem.Problem.set_initial_condition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。