hoppe93 / soft2 Goto Github PK
View Code? Open in Web Editor NEWHome of the SOFT2 synthetic diagnostic code
License: Other
Home of the SOFT2 synthetic diagnostic code
License: Other
Hi Mathias,
Do you have an example numerical distribution function for running SOFT2? I tried to create one for testing purposes with the following script, but I'm messing up somewhere since SOFT2 is returning zeros for my image.
ngrid = 51
r = np.zeros([1,51])
r[0,:] = np.linspace(0,2.6,ngrid)
xi = np.zeros([1,51])
xi[0,:] = np.linspace(-1,1,ngrid)
p = np.zeros([1,51])
p[0,:] = np.linspace(0,5e7,ngrid)
veldim = len(xi[0,:])*len(p[0,:])
fvel = np.reshape(f, (1, veldim))
F = np.zeros((len(r[0,:]), veldim))
for i in range(0,len(r)):
F[i,:] = ones(veldim)
desc = 'Sample numerical dist'
name = 'samp'
punits = 'ev'
import h5py
dist = h5py.File('dist_sample.h5', 'w')
dist.create_dataset('description',data=desc )
dist.create_dataset('f', data=F)
dist.create_dataset('name', data=name)
dist.create_dataset('p', data=p)
dist.create_dataset('punits', data=punits)
dist.create_dataset('r', data=r)
dist.create_dataset('xi', data=xi)
dist.close()
Hi Mathias,
I'm trying to obtain the bremsstrahlung spectrum for several distribution functions and would like to use the Green output to make this process quicker. To make sure I'm doing the right thing I'm comparing the spectrum SOFT outputs with the spectrum I obtain when I manually convolve the Green output, distribution function and momentum-space Jacobian, but the results don't match.
To test this I'm outputting three arrays.
r12w
)r12w
, with_f = yes
)@DistributionFunction distfunc (numerical) {
name = "distfunc.h5";
}
@ParticleGenerator PGen {
a = 0.0, 1, 51;
p = 0.1, 60.1, 61;
xi = 0.6, 1.0, 41;
progress = yes;
}
@RadiationOutput spectrum (spectrum) {
output = "spectrum.h5";
common = all;
}
@RadiationOutput green_r12w (green) {
output = "green_r12w.h5";
common = all;
format = "r12w";
}
@RadiationOutput green_r12w_wf (green) {
output = "green_r12w_wf.h5";
common = all;
format = "r12w";
with_f = yes;
}
Then I load the outputs as follows (some details left out for clarity)
# Load arrays
file_spectrum = "C:/data/spectrum.h5"
file_green = "C:/data/green_r12w.h5"
file_green_wf = "C:/data/green_r12w_wf.h5"
file_distfunc = "C:/data/distfunc.h5"
spec = OutputSOFT(file_spectrum)
green = OutputSOFT(file_green)
green_wf = OutputSOFT(file_green_wf)
hf = h5py.File(file_distfunc, "r")
nr_ = len(hf["r"][:])
np_ = len(hf["r0/p"][:])
nxi_ = len(hf["r0/xi"][:])
f = np.zeros((nr_, np_, nxi_))
for i in range(nr_):
f[i, :, :] = hf["r%i" % i]["f"][:].T
hf.close()
When I internally multiply the Green function and distribution in SOFT and then manually apply the Jacobian I get a 1-to-1 correspondence with the SOFT spectrum output.
# Multiply Green function (with_f) and Jacobian
G = green_wf.func.copy() # shape (51, 61, 41, 31)
I = np.einsum('ijkl,j->l', GF, green.param1**2) * dr * dp * dxi
print(I[:-1] / spec.I[:-1])
>>> [1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.]
But, when I manually multiply the Green function with the distribution function and then momentum space Jacobian, the result does not correspond to the spectrum calculated by SOFT.
F = f.copy() # shape (51, 61, 41)
G = green.func.copy() # shape (51, 61, 41, 31)
GF = np.einsum('ijkl,ijk->ijkl', G, F)
I = np.einsum('ijkl,j->l', GF, green.param1**2) * dr * dp * dxi
print(I[:-1] / spec.I[:-1])
>>> [1.40830086 1.40843453 1.40852022 1.40859633 1.40866617 1.40873123
1.40879381 1.40885874 1.40893586 1.40904543 1.40923222 1.4096119
1.41044905 1.41257196 1.42014974 1.41943928 1.39460177 1.32896809
1.24903276 1.20116468 1.13505426 1.05543201 1.0009113 0.96860324
0.96674995 0.96428314 0.96181247 0.95918242 0.95624132 0.96044473]
When I enable the with_f
flag in the green output module, what is SOFT doing different internally besides a tensor multiplication between the Green function and distribution function? Is there something besides the guiding-center and momentum-space Jacobian I'm forgetting? I did check the source code, but wasn't able to find a solution. If you could help me clarify this, I'd appreciate it.
Thanks.
The global_image
member (and its siblings) of the Image
radiation output class is static. This was previously used also in the Green's function module, but rewritten since static variables do not allow for multiple radiation output modules of the same kind to be used.
In this case, it causes global_image
to be deleted by the first module using it so that the second module is unable to access the image (and triggers a segmentation fault).
Hey
I ran into an error compiling SOFT2 (softlib built fine)
Here is the build script
+ mkdir SOFT
+ cd SOFT
+ git clone https://github.com/hoppe93/softlib.git
Cloning into 'softlib'...
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 911 (delta 5), reused 9 (delta 2), pack-reused 891
Receiving objects: 100% (911/911), 5.94 MiB | 2.91 MiB/s, done.
Resolving deltas: 100% (597/597), done.
Checking connectivity... done.
+ git clone https://github.com/hoppe93/SOFT2.git
Cloning into 'SOFT2'...
remote: Enumerating objects: 19, done.
remote: Counting objects: 100% (19/19), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 3146 (delta 2), reused 4 (delta 1), pack-reused 3127
Receiving objects: 100% (3146/3146), 1.85 MiB | 0 bytes/s, done.
Resolving deltas: 100% (2121/2121), done.
Checking connectivity... done.
+ cd softlib
+ mkdir build
+ cd build
+ cmake ../
-- The CXX compiler identification is GNU 7.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8")
-- Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Found GSL: /usr/include (found version "2.1")
INFONo libpng was found. Configuring without PNG image support...
-- HDF5: Using hdf5 compiler wrapper to determine CXX configuration
-- Found HDF5: /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_cpp.so;/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/x86_64-linux-gnu/libsz.so;/usr/lib/x86_64-linux-gnu/libz.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libm.so (found version "1.8.16") found components: CXX
-- Configuring done
-- Generating done
-- Build files have been written to: /SOFT/softlib/build
+ make
Scanning dependencies of target softlib
[ 2%] Building CXX object src/CMakeFiles/softlib.dir/Configuration/ConfigBlock.cpp.o
[ 4%] Building CXX object src/CMakeFiles/softlib.dir/Configuration/Script/ConfigToken.cpp.o
[ 7%] Building CXX object src/CMakeFiles/softlib.dir/Configuration/Configuration.cpp.o
[ 9%] Building CXX object src/CMakeFiles/softlib.dir/Configuration/Script/ConfigurationScript.cpp.o
[ 11%] Building CXX object src/CMakeFiles/softlib.dir/Configuration/Script/Interpreter.cpp.o
[ 14%] Building CXX object src/CMakeFiles/softlib.dir/Configuration/Script/Lexer.cpp.o
[ 16%] Building CXX object src/CMakeFiles/softlib.dir/Configuration/Script/SettingScript.cpp.o
[ 19%] Building CXX object src/CMakeFiles/softlib.dir/Configuration/SFile/SettingSFile.cpp.o
[ 21%] Building CXX object src/CMakeFiles/softlib.dir/Configuration/Setting.cpp.o
[ 23%] Building CXX object src/CMakeFiles/softlib.dir/General/SOFTLibException.cpp.o
[ 26%] Building CXX object src/CMakeFiles/softlib.dir/General/ProgressTracker.cpp.o
[ 28%] Building CXX object src/CMakeFiles/softlib.dir/General/Timer.cpp.o
[ 30%] Building CXX object src/CMakeFiles/softlib.dir/SFile/SFile.cpp.o
[ 33%] Building CXX object src/CMakeFiles/softlib.dir/SFile/SFile_SDT.cpp.o
[ 35%] Building CXX object src/CMakeFiles/softlib.dir/SFile/SFile_SDT.load.cpp.o
[ 38%] Building CXX object src/CMakeFiles/softlib.dir/SFile/SFile_HDF5.cpp.o
[ 40%] Building CXX object src/CMakeFiles/softlib.dir/SFile/SFile_MAT.HDF5.cpp.o
[ 42%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/AnalyticalAvalanche.cpp.o
[ 45%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/BesselRadialProfile.cpp.o
[ 47%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/CODEDistributionFunction.cpp.o
[ 50%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/ConnorHastieDistribution.cpp.o
[ 52%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/ExponentialPitch.cpp.o
[ 54%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/GOCODEDistributionFunction.cpp.o
[ 57%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/LinearRadialProfile.cpp.o
[ 59%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/LUKEDistributionFunction.cpp.o
[ 61%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/MomentumSpaceDistributionFunction.cpp.o
[ 64%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/NumericDistributionFunction.cpp.o
[ 66%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/NumericMomentumSpaceDistributionFunction.cpp.o
[ 69%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/PowerRadialProfile.cpp.o
[ 71%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/RadialDistributionFunction.cpp.o
[ 73%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/deprSOFTDistributionFunction.cpp.o
[ 76%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/SOFTDistributionFunction.cpp.o
[ 78%] Building CXX object src/CMakeFiles/softlib.dir/DistributionFunction/UnitDistributionFunction.cpp.o
[ 80%] Building CXX object src/CMakeFiles/softlib.dir/ImageGenerator/ImageGenerator.cpp.o
[ 83%] Building CXX object src/CMakeFiles/softlib.dir/ImageGenerator/ImageGeneratorPPM.cpp.o
[ 85%] Building CXX object src/CMakeFiles/softlib.dir/Integration/PeakedIntegration.cpp.o
[ 88%] Building CXX object src/CMakeFiles/softlib.dir/MagneticField/MagneticField2D.cpp.o
[ 90%] Building CXX object src/CMakeFiles/softlib.dir/MagneticField/MagneticFieldNumeric2D.cpp.o
[ 92%] Building CXX object src/CMakeFiles/softlib.dir/MagneticField/MagneticFieldAnalytical2D.cpp.o
[ 95%] Building CXX object src/CMakeFiles/softlib.dir/MagneticField/MagneticFieldAnalytical2D.q.cpp.o
[ 97%] Building CXX object src/CMakeFiles/softlib.dir/MagneticField/MagneticFieldLUKE.cpp.o
[100%] Linking CXX static library libsoftlib.a
[100%] Built target softlib
+ cd ../../SOFT2/build
+ cmake ../
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Found SOFTLIB: /SOFT/softlib/build/src/libsoftlib.a
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Found GSL: /usr/include (found version "2.1")
-- /usr/lib/x86_64-linux-gnu/libgsl.so/usr/lib/x86_64-linux-gnu/libgslcblas.so
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8")
-- Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
INFONo libpng was found. Configuring without PNG image support...
-- HDF5: Using hdf5 compiler wrapper to determine CXX configuration
-- Found HDF5: /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_cpp.so;/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/x86_64-linux-gnu/libsz.so;/usr/lib/x86_64-linux-gnu/libz.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libm.so (found version "1.8.16") found components: CXX
-- Configuring done
-- Generating done
-- Build files have been written to: /SOFT/SOFT2/build
+ make
Scanning dependencies of target soft
[ 1%] Building CXX object src/CMakeFiles/soft.dir/Main.cpp.o
/SOFT/SOFT2/src/Main.cpp:8:10: fatal error: softlib/Configuration/ConfigurationScript.h: No such file or directory
#include <softlib/Configuration/ConfigurationScript.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
src/CMakeFiles/soft.dir/build.make:62: recipe for target 'src/CMakeFiles/soft.dir/Main.cpp.o' failed
make[2]: *** [src/CMakeFiles/soft.dir/Main.cpp.o] Error 1
CMakeFiles/Makefile2:90: recipe for target 'src/CMakeFiles/soft.dir/all' failed
make[1]: *** [src/CMakeFiles/soft.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
When using two arguments for pixels (e.g. pixels = 600 300), the resulting image (e.g. png) somehow seems to "overlap" the images. Try changing the pixels in /examples/Image/pi and you'll see this. Perhaps this is a problem with the plotting function and not the actual SOFT simulation?
Also, it seems that pixels = X Y leads to X vertical pixels and Y horizontal pixels, when I would have expected the other way, e.g. pixels = 600 300 makes a tall, skinny image.
When running with the @Orbits
tool and @Radiation
tool simultaneously, the former can disable the calculation of the R/tau jacobian (Jdtdrho
) which gives it the default value 0, thus causing all radiation calculated by the @Radiation
tool to be set to 0.
There are two simple workarounds to this problem:
(1) specify the @Radiation
tool last in the list of tools: tools = orbits,rad;
(2) add the computeJacobian = yes;
option to the @Orbits
tool.
The desired behaviour should be for @Radiation
to take precedence so that, when used, the jacobian is always calculated. This could perhaps be achieved by making it impossible to disable calculation of the jacobian. The call to ParticlePusher::ToggleJacobianCalculation()
should thus only enable the jacobian calculation, with the default value being to not calculate the jacobian.
DREAM output files may contain two different distribution functions. It appears SOFT always throws an error when the distribution function to use is explicitly specified.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.