Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Antibody Kinetics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Hussels
Antibody Kinetics
Commits
358abe18
Commit
358abe18
authored
8 months ago
by
Yannik Hein
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
d77853fc
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Runge_Kutta_solution.py
+76
-0
76 additions, 0 deletions
Runge_Kutta_solution.py
with
76 additions
and
0 deletions
Runge_Kutta_solution.py
0 → 100644
+
76
−
0
View file @
358abe18
import
numpy
as
np
import
matplotlib.pyplot
as
plt
plt
.
rcParams
[
'
font.size
'
]
=
14
plt
.
rcParams
[
'
font.family
'
]
=
'
Times New Roman
'
def
dydt
(
t
,
Y
,
Kp
,
Km
,
X0
,
A0
):
return
Kp
*
(
X0
-
Y
)
*
(
A0
-
Y
)
-
Km
*
Y
def
runge_kutta
(
h
,
t_max
,
Kp
,
Km
,
X0
,
A0
):
t_values
=
np
.
arange
(
0
,
t_max
+
h
,
h
)
y_values
=
np
.
zeros
(
len
(
t_values
))
y
=
0
for
i
in
range
(
1
,
len
(
t_values
)):
t
=
t_values
[
i
-
1
]
k1
=
h
*
dydt
(
t
,
y
,
Kp
,
Km
,
X0
,
A0
)
k2
=
h
*
dydt
(
t
+
0.5
*
h
,
y
+
0.5
*
k1
,
Kp
,
Km
,
X0
,
A0
)
k3
=
h
*
dydt
(
t
+
0.5
*
h
,
y
+
0.5
*
k2
,
Kp
,
Km
,
X0
,
A0
)
k4
=
h
*
dydt
(
t
+
h
,
y
+
k3
,
Kp
,
Km
,
X0
,
A0
)
y
+=
(
k1
+
2
*
k2
+
2
*
k3
+
k4
)
/
6
y_values
[
i
]
=
y
return
t_values
,
y_values
#Set the parameters.
#Association constant k+.
Kp
=
@Kp
#Dissociation constant k-.
Km
=
@Km
#Initial free binding sites X0 (receptors or antigens).
X0
=
@Xo
#Initial AB concentration A0.
A0
=
@A0
#Step width of Runge-Kutta algorythm. Can be set to 0.1 for rough estimation.
h
=
@h0
#Measuring time t_max.
t_max
=
@t_max
#Insert time points.
t_data
=
@t_data
#@t_data=np.array([t1,t2,t3,...])
#Insert MFI data.
y_data
=
@y_data
#@y_data=np.array([y1,y2,y3,...])
#Insert y standard deviation.
stdev_data
=
@stdev_data
#@stdev_data=np.array([stdev1,stdev2,stdev3,...])
t_values
,
y_values
=
runge_kutta
(
h
,
t_max
,
Kp
,
Km
,
X0
,
A0
)
plt
.
plot
(
t_data
,
y_data
,
'
o
'
,
color
=
'
green
'
,
label
=
'
Label
'
)
#Plot the results.
plt
.
plot
(
t_values
,
y_values
,
color
=
'
#8A2BE2
'
,
label
=
'
Runge-Kutta Solution
'
)
lower_bound
=
y_data
-
stdev_data
upper_bound
=
y_data
+
stdev_data
plt
.
fill_between
(
t_data
,
lower_bound
,
upper_bound
,
color
=
'
lightgreen
'
,
alpha
=
0.3
,
label
=
'
SD
'
)
plt
.
xlabel
(
'
Time in s
'
)
plt
.
ylabel
(
'
MFI
'
)
plt
.
legend
(
prop
=
{
'
weight
'
:
'
bold
'
},
loc
=
'
lower right
'
)
plt
.
title
(
'
Title
'
,
fontweight
=
'
bold
'
)
#Plot limits.
plt
.
xlim
(
-
5
,
3600
)
plt
.
ylim
(
0
,
150
)
ax
=
plt
.
gca
()
ax
.
spines
[
'
top
'
].
set_visible
(
False
)
ax
.
spines
[
'
right
'
].
set_visible
(
False
)
#plt.savefig('Figure.png', bbox_inches='tight')
plt
.
show
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment