Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
c9895336
Commit
c9895336
authored
4 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
SampleToPython: further simplify
parent
f1873fb4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Core/Export/SampleToPython.cpp
+4
-10
4 additions, 10 deletions
Core/Export/SampleToPython.cpp
with
4 additions
and
10 deletions
Core/Export/SampleToPython.cpp
+
4
−
10
View file @
c9895336
...
@@ -19,7 +19,6 @@
...
@@ -19,7 +19,6 @@
#include
"Core/Export/PyFmt.h"
#include
"Core/Export/PyFmt.h"
#include
"Core/Export/PyFmt2.h"
#include
"Core/Export/PyFmt2.h"
#include
"Core/Export/ModelKeyHandler.h"
#include
"Core/Export/ModelKeyHandler.h"
#include
"Param/Varia/ParameterUtils.h"
#include
"Sample/Aggregate/InterferenceFunctions.h"
#include
"Sample/Aggregate/InterferenceFunctions.h"
#include
"Sample/Aggregate/ParticleLayout.h"
#include
"Sample/Aggregate/ParticleLayout.h"
#include
"Sample/Lattice/Lattice2D.h"
#include
"Sample/Lattice/Lattice2D.h"
...
@@ -37,7 +36,6 @@
...
@@ -37,7 +36,6 @@
#include
"Sample/Slice/LayerRoughness.h"
#include
"Sample/Slice/LayerRoughness.h"
#include
<iomanip>
#include
<iomanip>
#include
<map>
#include
<map>
#include
<set>
using
pyfmt
::
indent
;
using
pyfmt
::
indent
;
...
@@ -159,14 +157,11 @@ std::string SampleToPython::defineMaterials() const {
...
@@ -159,14 +157,11 @@ std::string SampleToPython::defineMaterials() const {
result
<<
indent
()
<<
"# Define materials
\n
"
;
result
<<
indent
()
<<
"# Define materials
\n
"
;
for
(
const
auto
*
s
:
v
)
{
for
(
const
auto
*
s
:
v
)
{
const
std
::
string
&
key
=
m_objs
->
obj2key
(
s
);
const
std
::
string
&
key
=
m_objs
->
obj2key
(
s
);
const
auto
factory_name
=
factory_names
.
find
(
s
->
typeID
());
const
std
::
string
&
factory_name
=
factory_names
.
at
(
s
->
typeID
());
if
(
factory_name
==
factory_names
.
cend
())
throw
std
::
runtime_error
(
"Error in ExportToPython::defineMaterials(): unknown material type"
);
const
complex_t
&
data
=
s
->
materialData
();
const
complex_t
&
data
=
s
->
materialData
();
if
(
s
->
isScalarMaterial
())
{
if
(
s
->
isScalarMaterial
())
{
result
<<
indent
()
<<
key
<<
" = ba."
result
<<
indent
()
<<
key
<<
" = ba."
<<
factory_name
->
second
<<
"(
\"
"
<<
s
->
getName
()
<<
"
\"
, "
<<
factory_name
<<
"(
\"
"
<<
s
->
getName
()
<<
"
\"
, "
<<
pyfmt
::
printDouble
(
data
.
real
())
<<
", "
<<
pyfmt
::
printDouble
(
data
.
real
())
<<
", "
<<
pyfmt
::
printDouble
(
data
.
imag
())
<<
")
\n
"
;
<<
pyfmt
::
printDouble
(
data
.
imag
())
<<
")
\n
"
;
}
else
{
}
else
{
...
@@ -174,7 +169,7 @@ std::string SampleToPython::defineMaterials() const {
...
@@ -174,7 +169,7 @@ std::string SampleToPython::defineMaterials() const {
result
<<
indent
()
<<
"magnetic_field = kvector_t("
<<
magnetic_field
.
x
()
<<
", "
result
<<
indent
()
<<
"magnetic_field = kvector_t("
<<
magnetic_field
.
x
()
<<
", "
<<
magnetic_field
.
y
()
<<
", "
<<
magnetic_field
.
z
()
<<
")
\n
"
;
<<
magnetic_field
.
y
()
<<
", "
<<
magnetic_field
.
z
()
<<
")
\n
"
;
result
<<
indent
()
<<
key
<<
" = ba."
result
<<
indent
()
<<
key
<<
" = ba."
<<
factory_name
->
second
<<
"(
\"
"
<<
s
->
getName
();
<<
factory_name
<<
"(
\"
"
<<
s
->
getName
();
result
<<
"
\"
, "
<<
pyfmt
::
printDouble
(
data
.
real
())
<<
", "
result
<<
"
\"
, "
<<
pyfmt
::
printDouble
(
data
.
real
())
<<
", "
<<
pyfmt
::
printDouble
(
data
.
imag
())
<<
", "
<<
pyfmt
::
printDouble
(
data
.
imag
())
<<
", "
<<
"magnetic_field)
\n
"
;
<<
"magnetic_field)
\n
"
;
...
@@ -431,8 +426,7 @@ std::string SampleToPython::defineParticleDistributions() const {
...
@@ -431,8 +426,7 @@ std::string SampleToPython::defineParticleDistributions() const {
std
::
ostringstream
result
;
std
::
ostringstream
result
;
result
<<
std
::
setprecision
(
12
);
result
<<
std
::
setprecision
(
12
);
result
<<
"
\n
"
<<
indent
()
<<
"# Define particles with parameter following a distribution
\n
"
;
result
<<
"
\n
"
<<
indent
()
<<
"# Define particles with parameter following a distribution
\n
"
;
int
index
=
1
;
int
index
(
1
);
for
(
const
auto
*
s
:
v
)
{
for
(
const
auto
*
s
:
v
)
{
const
std
::
string
&
key
=
m_objs
->
obj2key
(
s
);
const
std
::
string
&
key
=
m_objs
->
obj2key
(
s
);
const
std
::
string
units
=
s
->
mainUnits
();
const
std
::
string
units
=
s
->
mainUnits
();
...
...
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