Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Eisgenerator
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
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Klemm, Carl Philipp
Eisgenerator
Commits
a1867276
Commit
a1867276
authored
Mar 11, 2024
by
Carl Philipp Klemm
Browse files
Options
Downloads
Patches
Plain Diff
fvalueEq: handle eadge case at 0 where epsilon is zero
parent
d1d8668b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
basicmath.cpp
+2
-2
2 additions, 2 deletions
basicmath.cpp
eisgenerator/eistype.h
+2
-1
2 additions, 1 deletion
eisgenerator/eistype.h
eisgenerator/model.h
+21
-1
21 additions, 1 deletion
eisgenerator/model.h
eistype.cpp
+14
-0
14 additions, 0 deletions
eistype.cpp
model.cpp
+32
-2
32 additions, 2 deletions
model.cpp
with
71 additions
and
6 deletions
basicmath.cpp
+
2
−
2
View file @
a1867276
...
...
@@ -248,7 +248,7 @@ void eis::removeDuplicates(std::vector<eis::DataPoint>& data)
bool
eis
::
fvalueEq
(
fvalue
a
,
fvalue
b
,
unsigned
int
ulp
)
{
fvalue
epsilon
=
std
::
numeric_limits
<
fvalue
>::
epsilon
()
*
std
::
fabs
(
a
+
b
)
*
ulp
;
return
a
-
epsilon
<
b
&&
a
+
epsilon
>
b
;
return
a
-
epsilon
<
=
b
&&
a
+
epsilon
>
=
b
;
}
static
std
::
pair
<
std
::
vector
<
eis
::
DataPoint
>::
const_iterator
,
std
::
vector
<
eis
::
DataPoint
>::
const_iterator
>
...
...
@@ -412,7 +412,7 @@ std::vector<eis::DataPoint> eis::fitToFrequencies(std::vector<fvalue> omegas, co
return
out
;
}
void
difference
(
std
::
vector
<
eis
::
DataPoint
>&
a
,
const
std
::
vector
<
eis
::
DataPoint
>&
b
)
void
eis
::
difference
(
std
::
vector
<
eis
::
DataPoint
>&
a
,
const
std
::
vector
<
eis
::
DataPoint
>&
b
)
{
assert
(
a
.
size
()
==
b
.
size
());
for
(
size_t
i
=
0
;
i
<
a
.
size
();
++
i
)
...
...
This diff is collapsed.
Click to expand it.
eisgenerator/eistype.h
+
2
−
1
View file @
a1867276
...
...
@@ -445,9 +445,10 @@ public:
/**
* @brief Returns the a vector of DataPoints as a pair of valarrays.
*
* @param data the data to transform to valarrays
* @return A pair of valarrays, first the real part and second the imaginary part.
*/
std
::
pair
<
std
::
valarray
<
fvalue
>
,
std
::
valarray
<
fvalue
>>
eisToValarrays
(
const
std
::
vector
<
eis
::
DataPoint
>&
b
);
std
::
pair
<
std
::
valarray
<
fvalue
>
,
std
::
valarray
<
fvalue
>>
eisToValarrays
(
const
std
::
vector
<
eis
::
DataPoint
>&
data
);
/**
* @brief Returns the mean l2 element wise distance of the given spectra.
...
...
This diff is collapsed.
Click to expand it.
eisgenerator/model.h
+
21
−
1
View file @
a1867276
...
...
@@ -52,7 +52,7 @@ private:
static
size_t
paramSkipIndex
(
const
std
::
string
&
str
,
size_t
index
);
static
void
addComponantToFlat
(
Componant
*
componant
,
std
::
vector
<
Componant
*>*
flatComponants
);
static
void
sweepThreadFn
(
std
::
vector
<
std
::
vector
<
DataPoint
>>*
data
,
Model
*
model
,
size_t
start
,
size_t
stop
,
const
Range
&
omega
);
static
void
sweepThreadFn
(
std
::
vector
<
std
::
vector
<
DataPoint
>>*
data
,
Model
*
model
,
size_t
start
,
size_t
stop
,
const
std
::
vector
<
fvalue
>
&
omega
);
size_t
getActiveParameterCount
();
...
...
@@ -118,6 +118,26 @@ public:
*/
std
::
vector
<
DataPoint
>
executeSweep
(
const
std
::
vector
<
fvalue
>&
omega
,
size_t
index
=
0
);
/**
* @brief Executes a frequency and parameter sweep at the given parameter indecies
*
* @param omega The range along which to execute the frequency sweep.
* @param indecies the parameter indecies to include in the sweep
* @param parallel if this is set to true, the parameter sweep is executed in parallel
* @return A vector of vectors of DataPoint structs containing the impedance at every frequency sweep and parameter index.
*/
std
::
vector
<
std
::
vector
<
DataPoint
>>
executeSweeps
(
const
Range
&
omega
,
const
std
::
vector
<
size_t
>&
indecies
,
bool
parallel
=
false
);
/**
* @brief Executes a frequency and parameter sweep at the given parameter indecies
*
* @param omega A vector of frequencies in rad/s to calculate the impedance at.
* @param indecies the parameter indecies to include in the sweep
* @param parallel if this is set to true, the parameter sweep is executed in parallel
* @return A vector of vectors of DataPoint structs containing the impedance at every frequency sweep and parameter index.
*/
std
::
vector
<
std
::
vector
<
DataPoint
>>
executeSweeps
(
const
std
::
vector
<
fvalue
>&
omega
,
const
std
::
vector
<
size_t
>&
indecies
,
bool
parallel
=
false
);
/**
* @brief Executes a frequency sweep with the given omega values for each parameter combination in the applied parameter sweep.
*
...
...
This diff is collapsed.
Click to expand it.
eistype.cpp
+
14
−
0
View file @
a1867276
...
...
@@ -44,6 +44,20 @@ EisSpectra eis::loadFromDisk(const std::filesystem::path& path)
return
EisSpectra
(
path
);
}
std
::
pair
<
std
::
valarray
<
fvalue
>
,
std
::
valarray
<
fvalue
>>
eis
::
eisToValarrays
(
const
std
::
vector
<
eis
::
DataPoint
>&
data
)
{
std
::
valarray
<
fvalue
>
real
(
data
.
size
());
std
::
valarray
<
fvalue
>
imag
(
data
.
size
());
for
(
size_t
i
=
0
;
i
<
data
.
size
();
++
i
)
{
real
[
i
]
=
data
[
i
].
im
.
real
();
imag
[
i
]
=
data
[
i
].
im
.
imag
();
}
return
{
real
,
imag
};
}
void
eis
::
Range
::
print
(
int
level
)
const
{
Log
(
static_cast
<
Log
::
Level
>
(
level
))
<<
"Range "
<<
start
<<
'-'
<<
end
<<
' '
<<
count
<<
" steps"
<<
(
log
?
" Log"
:
""
);
...
...
This diff is collapsed.
Click to expand it.
model.cpp
+
32
−
2
View file @
a1867276
...
...
@@ -372,7 +372,37 @@ std::vector<DataPoint> Model::executeSweep(const std::vector<fvalue>& omega, siz
return
results
;
}
void
Model
::
sweepThreadFn
(
std
::
vector
<
std
::
vector
<
DataPoint
>>*
data
,
Model
*
model
,
size_t
start
,
size_t
stop
,
const
Range
&
omega
)
std
::
vector
<
std
::
vector
<
DataPoint
>>
Model
::
executeSweeps
(
const
Range
&
omega
,
const
std
::
vector
<
size_t
>&
indecies
,
bool
parallel
)
{
return
executeSweeps
(
omega
.
getRangeVector
(),
indecies
,
parallel
);
}
std
::
vector
<
std
::
vector
<
DataPoint
>>
Model
::
executeSweeps
(
const
std
::
vector
<
fvalue
>&
omega
,
const
std
::
vector
<
size_t
>&
indecies
,
bool
parallel
)
{
unsigned
int
threadsCount
=
parallel
?
std
::
thread
::
hardware_concurrency
()
:
1
;
if
(
indecies
.
size
()
<
threadsCount
*
10
)
threadsCount
=
1
;
size_t
countPerThread
=
indecies
.
size
()
/
threadsCount
;
std
::
vector
<
std
::
thread
>
threads
(
threadsCount
);
std
::
vector
<
Model
>
models
(
threadsCount
,
*
this
);
std
::
vector
<
std
::
vector
<
DataPoint
>>
data
(
indecies
.
size
());
for
(
size_t
i
=
0
;
i
<
threadsCount
;
++
i
)
{
size_t
start
=
i
*
countPerThread
;
size_t
stop
=
i
<
threadsCount
-
1
?
(
i
+
1
)
*
countPerThread
:
indecies
.
size
();
threads
[
i
]
=
std
::
thread
(
sweepThreadFn
,
&
data
,
&
models
[
i
],
start
,
stop
,
omega
);
}
for
(
size_t
i
=
0
;
i
<
threadsCount
;
++
i
)
threads
[
i
].
join
();
return
data
;
}
void
Model
::
sweepThreadFn
(
std
::
vector
<
std
::
vector
<
DataPoint
>>*
data
,
Model
*
model
,
size_t
start
,
size_t
stop
,
const
std
::
vector
<
fvalue
>&
omega
)
{
for
(
size_t
i
=
start
;
i
<
stop
;
++
i
)
{
...
...
@@ -396,7 +426,7 @@ std::vector<std::vector<DataPoint>> Model::executeAllSweeps(const Range& omega)
{
size_t
start
=
i
*
countPerThread
;
size_t
stop
=
i
<
threadsCount
-
1
?
(
i
+
1
)
*
countPerThread
:
count
;
threads
[
i
]
=
std
::
thread
(
sweepThreadFn
,
&
data
,
&
models
[
i
],
start
,
stop
,
std
::
ref
(
omega
));
threads
[
i
]
=
std
::
thread
(
sweepThreadFn
,
&
data
,
&
models
[
i
],
start
,
stop
,
omega
.
getRangeVector
(
));
}
for
(
size_t
i
=
0
;
i
<
threadsCount
;
++
i
)
threads
[
i
].
join
();
...
...
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