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
a939958c
Unverified
Commit
a939958c
authored
4 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
added plplot to test. not sure if it's cool enough though
parent
6d8f1281
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#12203
passed
4 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
practical_work/rc_circuit/Makefile
+3
-2
3 additions, 2 deletions
practical_work/rc_circuit/Makefile
practical_work/rc_circuit/main.c
+42
-1
42 additions, 1 deletion
practical_work/rc_circuit/main.c
with
45 additions
and
3 deletions
practical_work/rc_circuit/Makefile
+
3
−
2
View file @
a939958c
CC
=
clang
OPTS
=
-g
-O3
-Wall
-Wextra
-fsanitize
=
address
-fsanitize
=
leak
-std
=
c11
LINK
=
-lm
-fsanitize
=
address
-fsanitize
=
leak
INCLUDE
=
-I
/usr/include/plplot/
LINK
=
-lm
-fsanitize
=
address
-fsanitize
=
leak
-lplplot
# OPTS=-g -O3 -Wall -Wextra -std=c11
# LINK=-lm
...
...
@@ -9,7 +10,7 @@ main: main.o rc.o ode_o1.o
$(
CC
)
$(
OPTS
)
-o
$@
$^
$(
LINK
)
main.o
:
main.c
$(
CC
)
$(
OPTS
)
-c
$^
$(
CC
)
$(
OPTS
)
$(
INCLUDE
)
-c
$^
ode_o1.o
:
ode_o1.c ode_o1.h
$(
CC
)
$(
OPTS
)
-c
$^
...
...
This diff is collapsed.
Click to expand it.
practical_work/rc_circuit/main.c
+
42
−
1
View file @
a939958c
#include
"rc.h"
#include
<stdio.h>
#include
<stdlib.h>
#include
<math.h>
#include
<plplot.h>
int
main
()
{
#define NSIZE 5000
int
main
(
int
argc
,
char
*
argv
[])
{
rc_state
rc
=
rc_state_create
(
1
.
0
,
1
.
0
,
1
.
0
);
// ============================================================ //
// RC with constant != 0 tension at input and 0 initial tension //
// ============================================================ //
double
v
,
v_ini
;
v
=
v_ini
=
0
.
0
;
double
dt
=
0
.
001
;
double
max_t
=
5
.
0
;
int
i
=
0
;
PLFLT
x
[
NSIZE
],
y
[
NSIZE
];
PLFLT
xmin
=
0
.,
xmax
=
max_t
,
ymin
=
0
.,
ymax
=
rc
.
eps
;
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
);
x
[
i
]
=
t
;
y
[
i
]
=
v
;
v
=
rc_advance
(
v
,
dt
,
&
rc
);
i
+=
1
;
}
v
=
v_ini
=
1
.
0
;
double
omega
=
0
.
0
;
for
(
double
t
=
0
.
0
;
t
<
max_t
;
t
+=
dt
)
{
rc
.
eps
=
sin
(
omega
*
t
);
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
);
}
// Parse and process command line arguments
plparseopts
(
&
argc
,
argv
,
PL_PARSE_FULL
);
// Initialize plplot
plinit
();
// Create a labelled box to hold the plot.
plenv
(
xmin
,
xmax
,
ymin
,
ymax
,
0
,
0
);
pllab
(
"t"
,
"v"
,
"Simple PLplot demo of of the charge of a capacitor"
);
// Plot the data that was prepared above.
plline
(
NSIZE
,
x
,
y
);
// Close PLplot library
plend
();
return
EXIT_SUCCESS
;
}
\ 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