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
c2c2c02a
Commit
c2c2c02a
authored
4 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
SampleToPython: rm p_
parent
833c0b17
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Core/Export/SampleToPython.cpp
+103
-103
103 additions, 103 deletions
Core/Export/SampleToPython.cpp
with
103 additions
and
103 deletions
Core/Export/SampleToPython.cpp
+
103
−
103
View file @
c2c2c02a
...
...
@@ -108,23 +108,23 @@ std::string SampleToPython::defineMaterials() const
if
(
visitedMaterials
.
find
(
it
->
second
)
!=
visitedMaterials
.
end
())
continue
;
visitedMaterials
.
insert
(
it
->
second
);
const
Material
*
p_
material
=
it
->
first
;
const
auto
factory_name
=
factory_names
.
find
(
p_
material
->
typeID
());
const
Material
*
material
=
it
->
first
;
const
auto
factory_name
=
factory_names
.
find
(
material
->
typeID
());
if
(
factory_name
==
factory_names
.
cend
())
throw
std
::
runtime_error
(
"Error in ExportToPython::defineMaterials(): unknown material type"
);
const
complex_t
&
material_data
=
p_
material
->
materialData
();
if
(
p_
material
->
isScalarMaterial
())
{
result
<<
indent
()
<<
m_label
->
labelMaterial
(
p_
material
)
<<
" = ba."
<<
factory_name
->
second
<<
"(
\"
"
<<
p_
material
->
getName
()
<<
"
\"
, "
const
complex_t
&
material_data
=
material
->
materialData
();
if
(
material
->
isScalarMaterial
())
{
result
<<
indent
()
<<
m_label
->
labelMaterial
(
material
)
<<
" = ba."
<<
factory_name
->
second
<<
"(
\"
"
<<
material
->
getName
()
<<
"
\"
, "
<<
pyfmt
::
printDouble
(
material_data
.
real
())
<<
", "
<<
pyfmt
::
printDouble
(
material_data
.
imag
())
<<
")
\n
"
;
}
else
{
kvector_t
magnetic_field
=
p_
material
->
magnetization
();
kvector_t
magnetic_field
=
material
->
magnetization
();
result
<<
indent
()
<<
"magnetic_field = kvector_t("
<<
magnetic_field
.
x
()
<<
", "
<<
magnetic_field
.
y
()
<<
", "
<<
magnetic_field
.
z
()
<<
")
\n
"
;
result
<<
indent
()
<<
m_label
->
labelMaterial
(
p_
material
)
<<
" = ba."
<<
factory_name
->
second
<<
"(
\"
"
<<
p_
material
->
getName
();
result
<<
indent
()
<<
m_label
->
labelMaterial
(
material
)
<<
" = ba."
<<
factory_name
->
second
<<
"(
\"
"
<<
material
->
getName
();
result
<<
"
\"
, "
<<
pyfmt
::
printDouble
(
material_data
.
real
())
<<
", "
<<
pyfmt
::
printDouble
(
material_data
.
imag
())
<<
", "
<<
"magnetic_field)
\n
"
;
...
...
@@ -164,9 +164,9 @@ std::string SampleToPython::defineFormFactors() const
result
<<
std
::
setprecision
(
12
);
result
<<
"
\n
"
<<
indent
()
<<
"# Define Form Factors
\n
"
;
for
(
auto
it
=
themap
->
begin
();
it
!=
themap
->
end
();
++
it
)
{
const
IFormFactor
*
p_
ff
=
it
->
first
;
result
<<
indent
()
<<
it
->
second
<<
" = ba.FormFactor"
<<
p_
ff
->
getName
()
<<
"("
<<
pyfmt2
::
argumentList
(
p_
ff
)
<<
")
\n
"
;
const
IFormFactor
*
ff
=
it
->
first
;
result
<<
indent
()
<<
it
->
second
<<
" = ba.FormFactor"
<<
ff
->
getName
()
<<
"("
<<
pyfmt2
::
argumentList
(
ff
)
<<
")
\n
"
;
}
return
result
.
str
();
}
...
...
@@ -180,16 +180,16 @@ std::string SampleToPython::defineParticles() const
result
<<
std
::
setprecision
(
12
);
result
<<
"
\n
"
<<
indent
()
<<
"# Define Particles
\n
"
;
for
(
auto
it
=
themap
->
begin
();
it
!=
themap
->
end
();
++
it
)
{
const
Particle
*
p_
particle
=
it
->
first
;
const
Particle
*
particle
=
it
->
first
;
std
::
string
particle_name
=
it
->
second
;
auto
p_
ff
=
INodeUtils
::
OnlyChildOfType
<
IFormFactor
>
(
*
p_
particle
);
if
(
!
p_
ff
)
auto
ff
=
INodeUtils
::
OnlyChildOfType
<
IFormFactor
>
(
*
particle
);
if
(
!
ff
)
continue
;
result
<<
indent
()
<<
particle_name
<<
" = ba.Particle("
<<
m_label
->
labelMaterial
(
p_
particle
->
material
())
<<
", "
<<
m_label
->
labelFormFactor
(
p_
ff
)
<<
")
\n
"
;
setRotationInformation
(
p_
particle
,
particle_name
,
result
);
setPositionInformation
(
p_
particle
,
particle_name
,
result
);
<<
m_label
->
labelMaterial
(
particle
->
material
())
<<
", "
<<
m_label
->
labelFormFactor
(
ff
)
<<
")
\n
"
;
setRotationInformation
(
particle
,
particle_name
,
result
);
setPositionInformation
(
particle
,
particle_name
,
result
);
}
return
result
.
str
();
}
...
...
@@ -203,14 +203,14 @@ std::string SampleToPython::defineCoreShellParticles() const
result
<<
std
::
setprecision
(
12
);
result
<<
"
\n
"
<<
indent
()
<<
"# Define Core Shell Particles
\n
"
;
for
(
auto
it
=
themap
->
begin
();
it
!=
themap
->
end
();
++
it
)
{
const
ParticleCoreShell
*
p_
coreshell
=
it
->
first
;
const
ParticleCoreShell
*
coreshell
=
it
->
first
;
result
<<
"
\n
"
<<
indent
()
<<
it
->
second
<<
" = ba.ParticleCoreShell("
<<
m_label
->
labelParticle
(
p_
coreshell
->
shellParticle
())
<<
", "
<<
m_label
->
labelParticle
(
p_
coreshell
->
coreParticle
())
<<
")
\n
"
;
<<
m_label
->
labelParticle
(
coreshell
->
shellParticle
())
<<
", "
<<
m_label
->
labelParticle
(
coreshell
->
coreParticle
())
<<
")
\n
"
;
std
::
string
core_shell_name
=
it
->
second
;
setRotationInformation
(
p_
coreshell
,
core_shell_name
,
result
);
setPositionInformation
(
p_
coreshell
,
core_shell_name
,
result
);
setRotationInformation
(
coreshell
,
core_shell_name
,
result
);
setPositionInformation
(
coreshell
,
core_shell_name
,
result
);
}
return
result
.
str
();
}
...
...
@@ -227,11 +227,11 @@ std::string SampleToPython::defineParticleDistributions() const
int
index
(
1
);
for
(
auto
it
=
themap
->
begin
();
it
!=
themap
->
end
();
++
it
)
{
const
ParticleDistribution
*
p_
particle_distr
=
it
->
first
;
const
ParticleDistribution
*
particle_distr
=
it
->
first
;
const
std
::
string
units
=
p_
particle_distr
->
mainUnits
();
const
std
::
string
units
=
particle_distr
->
mainUnits
();
ParameterDistribution
par_distr
=
p_
particle_distr
->
parameterDistribution
();
ParameterDistribution
par_distr
=
particle_distr
->
parameterDistribution
();
// building distribution functions
std
::
string
s_distr
=
"distr_"
+
std
::
to_string
(
index
);
...
...
@@ -253,11 +253,11 @@ std::string SampleToPython::defineParticleDistributions() const
result
<<
"
\n
"
;
}
auto
p_
particle
=
INodeUtils
::
OnlyChildOfType
<
IParticle
>
(
*
p_
particle_distr
);
if
(
!
p_
particle
)
auto
particle
=
INodeUtils
::
OnlyChildOfType
<
IParticle
>
(
*
particle_distr
);
if
(
!
particle
)
continue
;
result
<<
indent
()
<<
it
->
second
<<
" = ba.ParticleDistribution("
<<
m_label
->
labelParticle
(
p_
particle
)
<<
", "
<<
s_par_distr
<<
")
\n
"
;
<<
m_label
->
labelParticle
(
particle
)
<<
", "
<<
s_par_distr
<<
")
\n
"
;
index
++
;
}
return
result
.
str
();
...
...
@@ -272,16 +272,16 @@ std::string SampleToPython::defineParticleCompositions() const
result
<<
std
::
setprecision
(
12
);
result
<<
"
\n
"
<<
indent
()
<<
"# Define composition of particles at specific positions
\n
"
;
for
(
auto
it
=
themap
->
begin
();
it
!=
themap
->
end
();
++
it
)
{
const
ParticleComposition
*
p_
particle_composition
=
it
->
first
;
const
ParticleComposition
*
particle_composition
=
it
->
first
;
std
::
string
particle_composition_name
=
it
->
second
;
result
<<
indent
()
<<
particle_composition_name
<<
" = ba.ParticleComposition()
\n
"
;
auto
particle_list
=
INodeUtils
::
ChildNodesOfType
<
IParticle
>
(
*
p_
particle_composition
);
for
(
auto
p_
particle
:
particle_list
)
{
auto
particle_list
=
INodeUtils
::
ChildNodesOfType
<
IParticle
>
(
*
particle_composition
);
for
(
auto
particle
:
particle_list
)
{
result
<<
indent
()
<<
particle_composition_name
<<
".addParticle("
<<
m_label
->
labelParticle
(
p_
particle
)
<<
")
\n
"
;
<<
m_label
->
labelParticle
(
particle
)
<<
")
\n
"
;
}
setRotationInformation
(
p_
particle_composition
,
particle_composition_name
,
result
);
setPositionInformation
(
p_
particle_composition
,
particle_composition_name
,
result
);
setRotationInformation
(
particle_composition
,
particle_composition_name
,
result
);
setPositionInformation
(
particle_composition
,
particle_composition_name
,
result
);
}
return
result
.
str
();
}
...
...
@@ -295,13 +295,13 @@ std::string SampleToPython::defineLattices2D() const
result
<<
std
::
setprecision
(
12
);
result
<<
"
\n
"
<<
indent
()
<<
"# Define 2D lattices
\n
"
;
for
(
auto
it
=
themap
->
begin
();
it
!=
themap
->
end
();
++
it
)
{
const
Lattice2D
*
p_
lattice
=
it
->
first
;
const
Lattice2D
*
lattice
=
it
->
first
;
std
::
string
lattice_name
=
it
->
second
;
result
<<
indent
()
<<
lattice_name
<<
" = ba.BasicLattice(
\n
"
;
result
<<
indent
()
<<
indent
()
<<
pyfmt
::
printNm
(
p_
lattice
->
length1
())
<<
", "
<<
pyfmt
::
printNm
(
p_
lattice
->
length2
())
<<
", "
<<
pyfmt
::
printNm
(
p_
lattice
->
latticeAngle
())
<<
"),
\n
"
;
<<
pyfmt
::
printNm
(
lattice
->
length1
())
<<
", "
<<
pyfmt
::
printNm
(
lattice
->
length2
())
<<
", "
<<
pyfmt
::
printNm
(
lattice
->
latticeAngle
())
<<
"),
\n
"
;
}
return
result
.
str
();
}
...
...
@@ -315,11 +315,11 @@ std::string SampleToPython::defineLattices3D() const
result
<<
std
::
setprecision
(
12
);
result
<<
"
\n
"
<<
indent
()
<<
"# Define 3D lattices
\n
"
;
for
(
auto
it
=
themap
->
begin
();
it
!=
themap
->
end
();
++
it
)
{
const
Lattice3D
*
p_
lattice
=
it
->
first
;
const
Lattice3D
*
lattice
=
it
->
first
;
std
::
string
lattice_name
=
it
->
second
;
kvector_t
bas_a
=
p_
lattice
->
getBasisVectorA
();
kvector_t
bas_b
=
p_
lattice
->
getBasisVectorB
();
kvector_t
bas_c
=
p_
lattice
->
getBasisVectorC
();
kvector_t
bas_a
=
lattice
->
getBasisVectorA
();
kvector_t
bas_b
=
lattice
->
getBasisVectorB
();
kvector_t
bas_c
=
lattice
->
getBasisVectorC
();
result
<<
indent
()
<<
lattice_name
<<
" = ba.Lattice3D(
\n
"
;
result
<<
indent
()
<<
indent
()
<<
"ba.kvector_t("
<<
pyfmt
::
printNm
(
bas_a
.
x
())
<<
", "
<<
pyfmt
::
printNm
(
bas_a
.
y
())
<<
", "
<<
pyfmt
::
printNm
(
bas_a
.
z
())
<<
"),
\n
"
;
...
...
@@ -340,15 +340,15 @@ std::string SampleToPython::defineCrystals() const
result
<<
std
::
setprecision
(
12
);
result
<<
"
\n
"
<<
indent
()
<<
"# Define crystals: basis particle + lattice
\n
"
;
for
(
auto
it
=
themap
->
begin
();
it
!=
themap
->
end
();
++
it
)
{
const
Crystal
*
p_
crystal
=
it
->
first
;
const
Crystal
*
crystal
=
it
->
first
;
std
::
string
crystal_name
=
it
->
second
;
auto
p_
lattice
=
INodeUtils
::
OnlyChildOfType
<
Lattice3D
>
(
*
p_
crystal
);
auto
p_
basis
=
INodeUtils
::
OnlyChildOfType
<
IParticle
>
(
*
p_
crystal
);
if
(
!
p_
lattice
||
!
p_
basis
)
auto
lattice
=
INodeUtils
::
OnlyChildOfType
<
Lattice3D
>
(
*
crystal
);
auto
basis
=
INodeUtils
::
OnlyChildOfType
<
IParticle
>
(
*
crystal
);
if
(
!
lattice
||
!
basis
)
continue
;
result
<<
indent
()
<<
crystal_name
<<
" = ba.Crystal("
;
result
<<
m_label
->
labelParticle
(
p_
basis
)
<<
", "
;
result
<<
m_label
->
labelLattice3D
(
p_
lattice
)
<<
")
\n
"
;
result
<<
m_label
->
labelParticle
(
basis
)
<<
", "
;
result
<<
m_label
->
labelLattice3D
(
lattice
)
<<
")
\n
"
;
}
return
result
.
str
();
}
...
...
@@ -362,17 +362,17 @@ std::string SampleToPython::defineMesoCrystals() const
result
<<
std
::
setprecision
(
12
);
result
<<
"
\n
"
<<
indent
()
<<
"# Define mesocrystals
\n
"
;
for
(
auto
it
=
themap
->
begin
();
it
!=
themap
->
end
();
++
it
)
{
const
MesoCrystal
*
p_
mesocrystal
=
it
->
first
;
const
MesoCrystal
*
mesocrystal
=
it
->
first
;
std
::
string
mesocrystal_name
=
it
->
second
;
auto
p_
crystal
=
INodeUtils
::
OnlyChildOfType
<
Crystal
>
(
*
p_
mesocrystal
);
auto
p_
outer_shape
=
INodeUtils
::
OnlyChildOfType
<
IFormFactor
>
(
*
p_
mesocrystal
);
if
(
!
p_
crystal
||
!
p_
outer_shape
)
auto
crystal
=
INodeUtils
::
OnlyChildOfType
<
Crystal
>
(
*
mesocrystal
);
auto
outer_shape
=
INodeUtils
::
OnlyChildOfType
<
IFormFactor
>
(
*
mesocrystal
);
if
(
!
crystal
||
!
outer_shape
)
continue
;
result
<<
indent
()
<<
mesocrystal_name
<<
" = ba.MesoCrystal("
;
result
<<
m_label
->
labelCrystal
(
p_
crystal
)
<<
", "
;
result
<<
m_label
->
labelFormFactor
(
p_
outer_shape
)
<<
")
\n
"
;
setRotationInformation
(
p_
mesocrystal
,
mesocrystal_name
,
result
);
setPositionInformation
(
p_
mesocrystal
,
mesocrystal_name
,
result
);
result
<<
m_label
->
labelCrystal
(
crystal
)
<<
", "
;
result
<<
m_label
->
labelFormFactor
(
outer_shape
)
<<
")
\n
"
;
setRotationInformation
(
mesocrystal
,
mesocrystal_name
,
result
);
setPositionInformation
(
mesocrystal
,
mesocrystal_name
,
result
);
}
return
result
.
str
();
}
...
...
@@ -390,85 +390,85 @@ std::string SampleToPython::defineInterferenceFunctions() const
if
(
dynamic_cast
<
const
InterferenceFunctionNone
*>
(
interference
))
result
<<
indent
()
<<
it
->
second
<<
" = ba.InterferenceFunctionNone()
\n
"
;
else
if
(
auto
p_
lattice_1d
=
else
if
(
auto
lattice_1d
=
dynamic_cast
<
const
InterferenceFunction1DLattice
*>
(
interference
))
{
result
<<
indent
()
<<
it
->
second
<<
" = ba.InterferenceFunction1DLattice("
<<
pyfmt
::
printNm
(
p_
lattice_1d
->
getLength
())
<<
", "
<<
pyfmt
::
printDegrees
(
p_
lattice_1d
->
getXi
())
<<
")
\n
"
;
<<
pyfmt
::
printNm
(
lattice_1d
->
getLength
())
<<
", "
<<
pyfmt
::
printDegrees
(
lattice_1d
->
getXi
())
<<
")
\n
"
;
auto
pdf
=
INodeUtils
::
OnlyChildOfType
<
IFTDecayFunction1D
>
(
*
p_
lattice_1d
);
auto
pdf
=
INodeUtils
::
OnlyChildOfType
<
IFTDecayFunction1D
>
(
*
lattice_1d
);
if
(
pdf
->
decayLength
()
!=
0.0
)
result
<<
indent
()
<<
it
->
second
<<
"_pdf = ba."
<<
pdf
->
getName
()
<<
"("
<<
pyfmt2
::
argumentList
(
pdf
)
<<
")
\n
"
<<
indent
()
<<
it
->
second
<<
".setDecayFunction("
<<
it
->
second
<<
"_pdf)
\n
"
;
}
else
if
(
auto
p_
para_radial
=
}
else
if
(
auto
para_radial
=
dynamic_cast
<
const
InterferenceFunctionRadialParaCrystal
*>
(
interference
))
{
result
<<
indent
()
<<
it
->
second
<<
" = ba.InterferenceFunctionRadialParaCrystal("
<<
pyfmt
::
printNm
(
p_
para_radial
->
peakDistance
())
<<
", "
<<
pyfmt
::
printNm
(
p_
para_radial
->
dampingLength
())
<<
")
\n
"
;
<<
pyfmt
::
printNm
(
para_radial
->
peakDistance
())
<<
", "
<<
pyfmt
::
printNm
(
para_radial
->
dampingLength
())
<<
")
\n
"
;
if
(
p_
para_radial
->
kappa
()
!=
0.0
)
if
(
para_radial
->
kappa
()
!=
0.0
)
result
<<
indent
()
<<
it
->
second
<<
".setKappa("
<<
pyfmt
::
printDouble
(
p_
para_radial
->
kappa
())
<<
")
\n
"
;
<<
pyfmt
::
printDouble
(
para_radial
->
kappa
())
<<
")
\n
"
;
if
(
p_
para_radial
->
domainSize
()
!=
0.0
)
if
(
para_radial
->
domainSize
()
!=
0.0
)
result
<<
indent
()
<<
it
->
second
<<
".setDomainSize("
<<
pyfmt
::
printDouble
(
p_
para_radial
->
domainSize
())
<<
")
\n
"
;
<<
pyfmt
::
printDouble
(
para_radial
->
domainSize
())
<<
")
\n
"
;
auto
pdf
=
INodeUtils
::
OnlyChildOfType
<
IFTDistribution1D
>
(
*
p_
para_radial
);
auto
pdf
=
INodeUtils
::
OnlyChildOfType
<
IFTDistribution1D
>
(
*
para_radial
);
if
(
pdf
->
omega
()
!=
0.0
)
result
<<
indent
()
<<
it
->
second
<<
"_pdf = ba."
<<
pdf
->
getName
()
<<
"("
<<
pyfmt2
::
argumentList
(
pdf
)
<<
")
\n
"
<<
indent
()
<<
it
->
second
<<
".setProbabilityDistribution("
<<
it
->
second
<<
"_pdf)
\n
"
;
}
else
if
(
auto
p_
lattice_2d
=
}
else
if
(
auto
lattice_2d
=
dynamic_cast
<
const
InterferenceFunction2DLattice
*>
(
interference
))
{
const
Lattice2D
&
lattice
=
p_
lattice_2d
->
lattice
();
const
Lattice2D
&
lattice
=
lattice_2d
->
lattice
();
result
<<
indent
()
<<
it
->
second
<<
" = ba.InterferenceFunction2DLattice("
<<
pyfmt
::
printNm
(
lattice
.
length1
())
<<
", "
<<
pyfmt
::
printNm
(
lattice
.
length2
())
<<
", "
<<
pyfmt
::
printDegrees
(
lattice
.
latticeAngle
())
<<
", "
<<
pyfmt
::
printDegrees
(
lattice
.
rotationAngle
())
<<
")
\n
"
;
auto
pdf
=
INodeUtils
::
OnlyChildOfType
<
IFTDecayFunction2D
>
(
*
p_
lattice_2d
);
auto
pdf
=
INodeUtils
::
OnlyChildOfType
<
IFTDecayFunction2D
>
(
*
lattice_2d
);
result
<<
indent
()
<<
it
->
second
<<
"_pdf = ba."
<<
pdf
->
getName
()
<<
"("
<<
pyfmt2
::
argumentList
(
pdf
)
<<
")
\n
"
<<
indent
()
<<
it
->
second
<<
".setDecayFunction("
<<
it
->
second
<<
"_pdf)
\n
"
;
if
(
p_
lattice_2d
->
integrationOverXi
()
==
true
)
if
(
lattice_2d
->
integrationOverXi
()
==
true
)
result
<<
indent
()
<<
it
->
second
<<
".setIntegrationOverXi(True)
\n
"
;
}
else
if
(
auto
p_
lattice_2d
=
}
else
if
(
auto
lattice_2d
=
dynamic_cast
<
const
InterferenceFunctionFinite2DLattice
*>
(
interference
))
{
const
Lattice2D
&
lattice
=
p_
lattice_2d
->
lattice
();
const
Lattice2D
&
lattice
=
lattice_2d
->
lattice
();
result
<<
indent
()
<<
it
->
second
<<
" = ba.InterferenceFunctionFinite2DLattice("
<<
pyfmt
::
printNm
(
lattice
.
length1
())
<<
", "
<<
pyfmt
::
printNm
(
lattice
.
length2
())
<<
", "
<<
pyfmt
::
printDegrees
(
lattice
.
latticeAngle
())
<<
", "
<<
pyfmt
::
printDegrees
(
lattice
.
rotationAngle
())
<<
", "
<<
p_
lattice_2d
->
numberUnitCells1
()
<<
", "
<<
p_
lattice_2d
->
numberUnitCells2
()
<<
lattice_2d
->
numberUnitCells1
()
<<
", "
<<
lattice_2d
->
numberUnitCells2
()
<<
")
\n
"
;
if
(
p_
lattice_2d
->
integrationOverXi
()
==
true
)
if
(
lattice_2d
->
integrationOverXi
()
==
true
)
result
<<
indent
()
<<
it
->
second
<<
".setIntegrationOverXi(True)
\n
"
;
}
else
if
(
auto
p_
para_2d
=
}
else
if
(
auto
para_2d
=
dynamic_cast
<
const
InterferenceFunction2DParaCrystal
*>
(
interference
))
{
std
::
vector
<
double
>
domainSize
=
p_
para_2d
->
domainSizes
();
const
Lattice2D
&
lattice
=
p_
para_2d
->
lattice
();
std
::
vector
<
double
>
domainSize
=
para_2d
->
domainSizes
();
const
Lattice2D
&
lattice
=
para_2d
->
lattice
();
result
<<
indent
()
<<
it
->
second
<<
" = ba.InterferenceFunction2DParaCrystal("
<<
pyfmt
::
printNm
(
lattice
.
length1
())
<<
", "
<<
pyfmt
::
printNm
(
lattice
.
length2
())
<<
", "
<<
pyfmt
::
printDegrees
(
lattice
.
latticeAngle
())
<<
", "
<<
pyfmt
::
printDegrees
(
lattice
.
rotationAngle
())
<<
", "
<<
pyfmt
::
printNm
(
p_
para_2d
->
dampingLength
())
<<
")
\n
"
;
<<
pyfmt
::
printNm
(
para_2d
->
dampingLength
())
<<
")
\n
"
;
if
(
domainSize
[
0
]
!=
0.0
||
domainSize
[
1
]
!=
0.0
)
result
<<
indent
()
<<
it
->
second
<<
".setDomainSizes("
<<
pyfmt
::
printNm
(
domainSize
[
0
])
<<
", "
<<
pyfmt
::
printNm
(
domainSize
[
1
])
<<
")
\n
"
;
if
(
p_
para_2d
->
integrationOverXi
()
==
true
)
if
(
para_2d
->
integrationOverXi
()
==
true
)
result
<<
indent
()
<<
it
->
second
<<
".setIntegrationOverXi(True)
\n
"
;
auto
pdf_vector
=
INodeUtils
::
ChildNodesOfType
<
IFTDistribution2D
>
(
*
p_
para_2d
);
auto
pdf_vector
=
INodeUtils
::
ChildNodesOfType
<
IFTDistribution2D
>
(
*
para_2d
);
if
(
pdf_vector
.
size
()
!=
2
)
continue
;
const
IFTDistribution2D
*
pdf
=
pdf_vector
[
0
];
...
...
@@ -482,11 +482,11 @@ std::string SampleToPython::defineInterferenceFunctions() const
<<
pyfmt2
::
argumentList
(
pdf
)
<<
")
\n
"
;
result
<<
indent
()
<<
it
->
second
<<
".setProbabilityDistributions("
<<
it
->
second
<<
"_pdf_1, "
<<
it
->
second
<<
"_pdf_2)
\n
"
;
}
else
if
(
auto
p_
lattice_hd
=
}
else
if
(
auto
lattice_hd
=
dynamic_cast
<
const
InterferenceFunctionHardDisk
*>
(
interference
))
{
result
<<
indent
()
<<
it
->
second
<<
" = ba.InterferenceFunctionHardDisk("
<<
pyfmt
::
printNm
(
p_
lattice_hd
->
radius
())
<<
", "
<<
pyfmt
::
printDouble
(
p_
lattice_hd
->
density
())
<<
")
\n
"
;
<<
pyfmt
::
printNm
(
lattice_hd
->
radius
())
<<
", "
<<
pyfmt
::
printDouble
(
lattice_hd
->
density
())
<<
")
\n
"
;
}
else
throw
Exceptions
::
NotImplementedException
(
"Bug: ExportToPython::defineInterferenceFunctions() called with unexpected "
...
...
@@ -514,15 +514,15 @@ std::string SampleToPython::defineParticleLayouts() const
result
<<
indent
()
<<
it
->
second
<<
" = ba.ParticleLayout()
\n
"
;
auto
particles
=
INodeUtils
::
ChildNodesOfType
<
IAbstractParticle
>
(
*
particleLayout
);
for
(
auto
p_
particle
:
particles
)
{
double
abundance
=
p_
particle
->
abundance
();
for
(
auto
particle
:
particles
)
{
double
abundance
=
particle
->
abundance
();
result
<<
indent
()
<<
it
->
second
<<
".addParticle("
<<
m_label
->
labelParticle
(
p_
particle
)
<<
", "
<<
m_label
->
labelParticle
(
particle
)
<<
", "
<<
pyfmt
::
printDouble
(
abundance
)
<<
")
\n
"
;
}
if
(
auto
p_
iff
=
INodeUtils
::
OnlyChildOfType
<
IInterferenceFunction
>
(
*
particleLayout
))
if
(
auto
iff
=
INodeUtils
::
OnlyChildOfType
<
IInterferenceFunction
>
(
*
particleLayout
))
result
<<
indent
()
<<
it
->
second
<<
".setInterferenceFunction("
<<
m_label
->
labelInterferenceFunction
(
p_
iff
)
<<
")
\n
"
;
<<
m_label
->
labelInterferenceFunction
(
iff
)
<<
")
\n
"
;
result
<<
indent
()
<<
it
->
second
<<
".setWeight("
<<
particleLayout
->
weight
()
<<
")
\n
"
;
result
<<
indent
()
<<
it
->
second
<<
".setTotalParticleSurfaceDensity("
<<
particleLayout
->
totalParticleSurfaceDensity
()
<<
")
\n
"
;
...
...
@@ -555,9 +555,9 @@ std::string SampleToPython::addLayoutsToLayers() const
const
auto
layermap
=
m_label
->
layerMap
();
for
(
auto
it
=
layermap
->
begin
();
it
!=
layermap
->
end
();
++
it
)
{
const
Layer
*
layer
=
it
->
first
;
for
(
auto
p_
layout
:
layer
->
layouts
())
for
(
auto
layout
:
layer
->
layouts
())
result
<<
"
\n
"
<<
indent
()
<<
it
->
second
<<
".addLayout("
<<
m_label
->
labelLayout
(
p_
layout
)
<<
indent
()
<<
it
->
second
<<
".addLayout("
<<
m_label
->
labelLayout
(
layout
)
<<
")
\n
"
;
}
return
result
.
str
();
...
...
@@ -614,33 +614,33 @@ std::string SampleToPython::indent() const
return
" "
;
}
void
SampleToPython
::
setRotationInformation
(
const
IParticle
*
p_
particle
,
std
::
string
name
,
void
SampleToPython
::
setRotationInformation
(
const
IParticle
*
particle
,
std
::
string
name
,
std
::
ostringstream
&
result
)
const
{
if
(
p_
particle
->
rotation
())
{
switch
(
p_
particle
->
rotation
()
->
getTransform3D
().
getRotationType
())
{
if
(
particle
->
rotation
())
{
switch
(
particle
->
rotation
()
->
getTransform3D
().
getRotationType
())
{
case
Transform3D
::
EULER
:
{
double
alpha
,
beta
,
gamma
;
p_
particle
->
rotation
()
->
getTransform3D
().
calculateEulerAngles
(
&
alpha
,
&
beta
,
&
gamma
);
particle
->
rotation
()
->
getTransform3D
().
calculateEulerAngles
(
&
alpha
,
&
beta
,
&
gamma
);
result
<<
indent
()
<<
name
<<
"_rotation = ba.RotationEuler("
<<
pyfmt
::
printDegrees
(
alpha
)
<<
", "
<<
pyfmt
::
printDegrees
(
beta
)
<<
", "
<<
pyfmt
::
printDegrees
(
gamma
)
<<
")
\n
"
;
break
;
}
case
Transform3D
::
XAXIS
:
{
double
alpha
=
p_
particle
->
rotation
()
->
getTransform3D
().
calculateRotateXAngle
();
double
alpha
=
particle
->
rotation
()
->
getTransform3D
().
calculateRotateXAngle
();
result
<<
indent
()
<<
name
<<
"_rotation = ba.RotationX("
<<
pyfmt
::
printDegrees
(
alpha
)
<<
")
\n
"
;
break
;
}
case
Transform3D
::
YAXIS
:
{
double
alpha
=
p_
particle
->
rotation
()
->
getTransform3D
().
calculateRotateYAngle
();
double
alpha
=
particle
->
rotation
()
->
getTransform3D
().
calculateRotateYAngle
();
result
<<
indent
()
<<
name
<<
"_rotation = ba.RotationY("
<<
pyfmt
::
printDegrees
(
alpha
)
<<
")
\n
"
;
break
;
}
case
Transform3D
::
ZAXIS
:
{
double
alpha
=
p_
particle
->
rotation
()
->
getTransform3D
().
calculateRotateZAngle
();
double
alpha
=
particle
->
rotation
()
->
getTransform3D
().
calculateRotateZAngle
();
result
<<
indent
()
<<
name
<<
"_rotation = ba.RotationZ("
<<
pyfmt
::
printDegrees
(
alpha
)
<<
")
\n
"
;
break
;
...
...
@@ -650,10 +650,10 @@ void SampleToPython::setRotationInformation(const IParticle* p_particle, std::st
}
}
void
SampleToPython
::
setPositionInformation
(
const
IParticle
*
p_
particle
,
std
::
string
name
,
void
SampleToPython
::
setPositionInformation
(
const
IParticle
*
particle
,
std
::
string
name
,
std
::
ostringstream
&
result
)
const
{
kvector_t
pos
=
p_
particle
->
position
();
kvector_t
pos
=
particle
->
position
();
bool
has_position_info
=
(
pos
!=
kvector_t
());
if
(
has_position_info
)
{
...
...
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