Skip to content

How do I use fall_drag parameters in the euler_step function? #3

Open
rcc02007 opened this issue Mar 12, 2020 · 1 comment
Open

How do I use fall_drag parameters in the euler_step function? #3

rcc02007 opened this issue Mar 12, 2020 · 1 comment

Comments

@rcc02007
Copy link
Owner

This question has come up 3-5x, so here goes:
How can I use the fall_drag parameters in the euler_step function
e.g.

for i in range(N-1):
    num_sol_drag[i+1] = eulerstep(num_sol_drag[i],fall_drag(state,C_d=0.47,m=0.0577,R = 0.0661/2), dt)
@rcc02007
Copy link
Owner Author

This is a great application of the lambda function:

for i in range(N-1):
    num_sol_drag[i+1] = eulerstep(num_sol_drag[i],\
                                    lambda state: fall_drag(state,C_d=0.47,m=0.0577,R = 0.0661/2), dt)

The euler_step is expecting a function of the form dstate = f(state), so you can create an anonymous function that is the form:

lambda state: f(state,parameter_1, parameter_2,...,parameterN)

@evg16108 evg16108 mentioned this issue Apr 3, 2020
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant