Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
isc_physics
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
Model registry
Operate
Environments
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
orestis.malaspin
isc_physics
Commits
6d8f1281
Unverified
Commit
6d8f1281
authored
4 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
updated rc code
parent
6336b792
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
practical_work/rc_circuit/main.c
+20
-0
20 additions, 0 deletions
practical_work/rc_circuit/main.c
practical_work/rc_circuit/rc.c
+23
-0
23 additions, 0 deletions
practical_work/rc_circuit/rc.c
with
43 additions
and
0 deletions
practical_work/rc_circuit/main.c
0 → 100644
+
20
−
0
View file @
6d8f1281
#include
"rc.h"
#include
<stdio.h>
#include
<stdlib.h>
int
main
()
{
rc_state
rc
=
rc_state_create
(
1
.
0
,
1
.
0
,
1
.
0
);
double
v
,
v_ini
;
v
=
v_ini
=
0
.
0
;
double
dt
=
0
.
001
;
double
max_t
=
5
.
0
;
for
(
double
t
=
0
.
0
;
t
<
max_t
;
t
+=
dt
)
{
double
ve
=
exact_solution
(
t
,
v_ini
,
&
rc
);
printf
(
"t = %f, v = %f, v_e = %f, diff = %f
\n
"
,
t
,
v
,
ve
,
ve
-
v
);
v
=
rc_advance
(
v
,
dt
,
&
rc
);
}
return
EXIT_SUCCESS
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
practical_work/rc_circuit/rc.c
0 → 100644
+
23
−
0
View file @
6d8f1281
#include
<math.h>
#include
"rc.h"
#include
"ode_o1.h"
rc_state
rc_state_create
(
double
r
,
double
c
,
double
eps
)
{
rc_state
rc
=
{.
r
=
r
,
.
c
=
c
,
.
eps
=
eps
};
return
rc
;
}
double
rc_g
(
double
v
,
void
*
rc
)
{
rc_state
*
rcs
=
(
rc_state
*
)
rc
;
return
1
.
0
/
(
rcs
->
r
*
rcs
->
c
)
*
(
rcs
->
eps
-
v
);
}
double
rc_advance
(
double
v0
,
double
dt
,
rc_state
*
state
)
{
return
advance
(
rc_g
,
v0
,
dt
,
state
);
}
double
exact_solution
(
double
t
,
double
v_ini
,
rc_state
*
state
)
{
return
v_ini
*
exp
(
-
t
/
(
state
->
c
*
state
->
r
))
-
state
->
eps
*
exp
(
-
t
/
(
state
->
c
*
state
->
r
))
+
state
->
eps
;
}
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