Commit 5fcd3e93 authored by Daniel Brown's avatar Daniel Brown

Merge branch 'develop' into tf3

parents 6249f991 c427a461
*.err
*.log
*.bak
*.m
*.py
*.gnu
*.py
*.out
kat.exe
kat
src/cuba.h
......
FROM debian
WORKDIR /root
RUN apt --assume-yes update
RUN apt --assume-yes install gcc git libgsl-dev make g++ python
RUN git clone https://git.ligo.org/finesse/finesse.git
CMD ["python", "/host/build.py"]
\ No newline at end of file
Builds an Debian package for the Finesse binary
Build docker image first:
docker build -t finesse/debian .
To create the rpm package:
docker run -it --volume=${PWD}:/host pykat/debian
This will build Finesse on the Docker image and an deb file will be returned in this folder.
\ No newline at end of file
import os
import textwrap
from subprocess import call, check_output
from collections import defaultdict
import string
class SafeDict(dict):
def __missing__(self, key):
return '{' + key + '}'
os.chdir("/root/finesse")
call("git pull".split())
call("./finesse.sh --build-linux".split())
os.chdir("/root/finesse/packaging/deb")
call("mkdir -p finesse/DEBIAN".split())
# e.g. Finesse 2.2 (2.2-18-g4e88fe48), 29.05.2018
git_describe = str(check_output('/root/finesse/kat -v'.split()))
version = git_describe.split()[2].strip('(').strip(')').split('-')
vals = {
"version": version[0],
"release": version[1],
}
print(vals)
call('mkdir -p finesse/DEBIAN'.format(**vals).split())
call('mkdir -p finesse/usr/bin'.format(**vals).split())
call('mkdir -p finesse/etc/finesse'.format(**vals).split())
call('cp /root/finesse/kat /root/finesse/packaging/deb/finesse/usr/bin'.format(**vals).split())
call('cp /root/finesse/kat.ini /root/finesse/packaging/deb/finesse/etc/finesse'.format(**vals).split())
with open("/root/finesse/packaging/deb/finesse/DEBIAN/control", "w") as f:
s = string.Formatter().vformat(textwrap.dedent("""
Package: finesse
Version: {version}.{release}
Section: base
Priority: optional
Architecture: amd64
Depends: gsl-bin
Maintainer: Daniel Brown <finesse@star.sr.bham.ac.uk>
Description: FINESSE: Frequency domain INterfErometer Simulation SoftwarE
"""), (), SafeDict(**vals))
f.write(s)
call("dpkg-deb --build finesse".split())
call("cp /root/finesse/packaging/deb/finesse.deb /host/finesse.{version}.{release}.deb".format(**vals).split())
\ No newline at end of file
FROM scientificlinux/sl:7
WORKDIR /root
RUN yum -y update
RUN yum -y install git rpm-build gcc gsl-devel make gcc-c++
RUN git clone https://git.ligo.org/finesse/finesse.git
CMD ["python", "/host/build.py"]
\ No newline at end of file
Builds an RPM package for the Finesse binary
Build docker image first:
docker build -t finesse/sl7 .
To create the rpm package:
docker run -it --volume=${PWD}:/host finesse/sl7
This will build Finesse on the Docker image and an rpm file will be returned in this folder.
\ No newline at end of file
import os
import textwrap
from subprocess import call, check_output
from collections import defaultdict
import string
class SafeDict(dict):
def __missing__(self, key):
return '{' + key + '}'
os.chdir("/root/finesse")
call("git pull".split())
git_describe = str(check_output('git describe --tags'.split())).split("-")
call("./finesse.sh --build-linux".split())
os.chdir("/root/finesse/packaging/rpm")
for d in "RPMS,SRPMS,BUILD,SOURCES,SPECS,tmp".split(","):
call("mkdir -p rpmbuild/{d}".format(d=d).split())
with open("/root/.rpmmacros", "w") as f:
f.write("%_topdir /root/finesse/packaging/rpm/rpmbuild\n")
f.write("%_tmppath %{_topdir}/tmp\n")
os.chdir("/root/finesse/packaging/rpm/rpmbuild")
vals = {
"version": git_describe[0],
"release": git_describe[1],
}
call('mkdir -p finesse-{version}'.format(**vals).split())
call('mkdir -p finesse-{version}/usr/bin'.format(**vals).split())
call('mkdir -p finesse-{version}/etc/finesse'.format(**vals).split())
call('cp /root/finesse/kat /root/finesse/packaging/rpm/rpmbuild/finesse-{version}/usr/bin'.format(**vals).split())
call('cp /root/finesse/kat.ini /root/finesse/packaging/rpm/rpmbuild/finesse-{version}/etc/finesse'.format(**vals).split())
call('tar -zcvf ./SOURCES/finesse-{version}-{release}.tar.gz finesse-{version}/'.format(**vals).split())
with open("/root/finesse/packaging/rpm/rpmbuild/SPECS/finesse.spec", "w") as f:
s = string.Formatter().vformat(textwrap.dedent("""
%define __spec_install_post %{nil}
%define debug_package %{nil}
%define __os_install_post %{_dbpath}/brp-compress
Summary: FINESSE: Frequency domain INterfErometer Simulation SoftwarE
Name: finesse
Version: {version}
Release: {release}
Requires: gsl
License: GPL
Group: Development/Tools
SOURCE0 : %{name}-%{{version}}-%{{release}}.tar.gz
URL: http://gwoptics.org/finesse
BuildRoot: %{_tmppath}/%{name}-%{{version}}-%{{release}}-root
%description
%{summary}
%prep
%setup -q
%build
# Empty section.
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}
# in builddir
cp -a * %{buildroot}
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%{_sysconfdir}/%{name}/kat.ini
%{_bindir}/*
%changelog
"""), (), SafeDict(**vals))
f.write(s)
call("rpmbuild -bb SPECS/finesse.spec".split())
call("cp /root/finesse/packaging/rpm/rpmbuild/RPMS/x86_64/finesse-{version}-{release}.x86_64.rpm /host".format(**vals).split())
\ No newline at end of file
......@@ -1553,18 +1553,26 @@ void prepare_merged_maps_comp(void* cmp, KNM_COMPONENT_t cmpid) {
if (!map->reflection) {
kr = 0.0;
Br = 0.0;
kt = -1.0 * k0;
map0->hasReflectionMaps = false;
// ddb - Not obviously clear but I'm guessing this minus sign flip is a
// coordinate defition difference but only in the case where only
// transmission maps are applied, no reflection. Why? I'm gussing
// this was a minus sign applied to get physics/maptest01.kat
// working correctly back when it was tried out. This is take a phase
// map of a lens and applying it to a mirror. I'm moving this minus
// sign into get_map_nr_definitions so it applies to all the integrators.
// Otherwise with multiple maps applied you can get odd sign flips.
// kt = -1.0 * k0;
map0->hasReflectionMaps |= false;
} else {
map0->hasReflectionMaps = true;
map0->hasReflectionMaps |= true;
}
if (!map->transmission) {
kt = 0.0;
Bt = 0.0;
map0->hasTransmissionMaps = false;
map0->hasTransmissionMaps |= false;
} else {
map0->hasTransmissionMaps = true;
map0->hasTransmissionMaps |= true;
}
for (i = 0; i < map0->cols; i++) {
......
......@@ -109,6 +109,79 @@ void create_newton_cotes_composite_weights(double *W, size_t length, int order)
}
}
void get_map_nr_sign_definitions(int knum, int knmcmp, double nr1, double nr2, double *phi, surface_merged_map_t *map) {
// See the doc string for interpolate_merged_map for a diagram of the axes involved.
// as the refractive index of the medium either side of a mirror could
// change in the simulation we must apply the refractive index terms of the
// phase here
switch(knmcmp){
case MIRROR_CMP:
switch (knum) {
case MR11:
*phi *= nr1;
break;
case MR12:
case MR21:
// if the phase map is transmission only we consider the surface profile
// to be flat thus no difference because of nr1 and nr2 should be seen
if (!map->phaseIsOnlyTransmission){
*phi *= (nr2 - nr1);
} else {
// extra minus sign here is for a change in map coordinate system, but only
// when trans maps rather than refl maps are used... Was originally in prepare_merged_maps
*phi *= -1;
}
break;
case MR22:
*phi *= nr2;
break;
}
break;
case BEAMSPLITTER_CMP:
switch (knum) {
case BS12:
case BS21:
*phi *= nr1;
break;
case BS13:
case BS31:
case BS24:
case BS42:
// if the phase map is transmission only we consider the surface profile
// to be flat thus no difference because of nr1 and nr2 should be seen
if (!map->phaseIsOnlyTransmission) {
*phi *= (nr2 - nr1);
} else {
// extra minus sign here is for a change in map coordinate system, but only
// when trans maps rather than refl maps are used... Was originally in prepare_merged_maps
*phi *= -1;
}
break;
case BS34:
case BS43:
*phi *= nr2;
break;
}
break;
}
//if we are only applying a transmission phase then the phase should be same
//whether we go from n1->n2 or n2->n1 as the T phase represents a "thickness"
//of the component not a surface displacement so phase sign flip not needed.
if (!map->phaseIsOnlyTransmission) {
// From the diagram above we see that z' needs to be inverted
// or that we just invert the sign of the phase, same thing
if ( knmcmp == MIRROR_CMP && ((knum == MR12) || (knum == MR22)))
(*phi) *= -1;
// same with beamsplitter, anything travelling in the 3/4 direction
if ( knmcmp == BEAMSPLITTER_CMP &&((knum == BS13) || (knum == BS34) || (knum == BS43) || (knum == BS24)))
(*phi) *= -1;
}
}
/**
* Merged map interpolation involves interpolating both the amplitude and phase
* of a merged map. Depending on which coupling coefficient you want to
......@@ -330,64 +403,7 @@ void interpolate_merged_map(surface_merged_map_t *map, KNM_COMPONENT_t knmcmp, i
}
}
// as the refractive index of the medium either side of a mirror could
// change in the simulation we must apply the refractive index terms of the
// phase here
switch(knmcmp){
case MIRROR_CMP:
switch (knum) {
case MR11:
*phi *= nr1;
break;
case MR12:
case MR21:
// if the phase map is transmission only we consider the surface profile
// to be flat thus no difference because of nr1 and nr2 should be seen
if (!map->phaseIsOnlyTransmission)
*phi *= (nr2 - nr1);
break;
case MR22:
*phi *= nr2;
break;
}
break;
case BEAMSPLITTER_CMP:
switch (knum) {
case BS12:
case BS21:
*phi *= nr1;
break;
case BS13:
case BS31:
case BS24:
case BS42:
// if the phase map is transmission only we consider the surface profile
// to be flat thus no difference because of nr1 and nr2 should be seen
if (!map->phaseIsOnlyTransmission)
*phi *= (nr2 - nr1);
break;
case BS34:
case BS43:
*phi *= nr2;
break;
}
break;
}
//if we are only applying a transmission phase then the phase should be same
//whether we go from n1->n2 or n2->n1 as the T phase represents a "thickness"
//of the component not a surface displacement so phase sign flip not needed.
if (!map->phaseIsOnlyTransmission) {
// From the diagram above we see that z' needs to be inverted
// or that we just invert the sign of the phase, same thing
if ( knmcmp == MIRROR_CMP && ((knum == MR12) || (knum == MR22)))
(*phi) *= -1;
// same with beamsplitter, anything travelling in the 3/4 direction
if ( knmcmp == BEAMSPLITTER_CMP &&((knum == BS13) || (knum == BS34) || (knum == BS43) || (knum == BS24)))
(*phi) *= -1;
}
get_map_nr_sign_definitions(knum, knmcmp, nr1, nr2, phi, map);
// When at a non-normal incidence we also need to increase the depth of a
// phase map. As the larger angle of incidence causes a longer path length
......@@ -1399,6 +1415,16 @@ void do_newton_cotes_int(void *userdata, KNM_COMPONENT_t knmcmp, complex_t *resu
gerror("Newton-Cotes sum does not support map rotations \n");
}
double f_phi_11 = 1;
double f_phi_12 = 1;
double f_phi_21 = 1;
double f_phi_22 = 1;
get_map_nr_sign_definitions(MR11, knmcmp, nr1, nr2, &f_phi_11, map);
get_map_nr_sign_definitions(MR12, knmcmp, nr1, nr2, &f_phi_12, map);
get_map_nr_sign_definitions(MR21, knmcmp, nr1, nr2, &f_phi_21, map);
get_map_nr_sign_definitions(MR22, knmcmp, nr1, nr2, &f_phi_22, map);
// now loop through each knm direction, check whether we should calculate
// the knm, then interpolate etc.
for (k = min_k; k <= max_k; k++) {
......@@ -1406,7 +1432,7 @@ void do_newton_cotes_int(void *userdata, KNM_COMPONENT_t knmcmp, complex_t *resu
// the calc flags are powers of 2 and stored in a flag
// use bit shift here to get the powers of 2 in the loop
unsigned int kk = ((unsigned int) (1 << (k - 1)));
// if we should be calculating this k continue
if ((knm_calc_flags & kk) == kk) {
if (knmcmp == MIRROR_CMP) {
......@@ -1469,29 +1495,40 @@ void do_newton_cotes_int(void *userdata, KNM_COMPONENT_t knmcmp, complex_t *resu
} else
gerror("knmcmp parameter not recognised");
if(kk == MR22Calc) {
// for reflection from side 2 we need a minus sign on the phase
// as the phase map is inverted in height. Also we see the
// map from the other side so need to reflect about y.
// Note here that we need to flip the x axis for the whole reflection
// coordinate system flip
if(kk == MR11Calc) {
for(i=0; i<(int)ndx; i++) {
for(j=0; j<(int)ndy; j++) {
u_xy[j][i] = z_by_xphr(u_xy[j][i], A[ndy-1-j][ndx-1-i], phi[ndy-1-j][ndx-1-i]);
u_xy[j][i] = z_by_xphr(u_xy[j][i], A[j][i], f_phi_11 * phi[j][ndx-1-i]);
}
}
} else {
} else if(kk == MR12Calc) {
for(i=0; i<(int)ndx; i++) {
for(j=0; j<(int)ndy; j++) {
u_xy[j][i] = z_by_xphr(u_xy[j][i], A[ndy-1-j][i], -phi[ndy-1-j][i]);
u_xy[j][i] = z_by_xphr(u_xy[j][i], A[j][i], f_phi_12 * phi[j][i]);
}
}
}
} else if(kk == MR21Calc) {
for(i=0; i<(int)ndx; i++) {
for(j=0; j<(int)ndy; j++) {
u_xy[j][i] = z_by_xphr(u_xy[j][i], A[j][i], f_phi_21 * phi[j][ndx-1-i]);
}
}
} else if(kk == MR22Calc) {
for(i=0; i<(int)ndx; i++) {
for(j=0; j<(int)ndy; j++) {
u_xy[j][i] = z_by_xphr(u_xy[j][i], A[j][i], f_phi_22 * phi[j][i]);
}
}
}
}
// As the zmatrix is allocated in one large block when
// using allocate_zmatrix(...) we can access it like a 1D array
complex_t *tmp = u_xy[0];
results[k-1] = complex_0;
for(i=0; i<(int)(ndx*ndy); i++) {
z_inc_z(results + k - 1, tmp[i]);
}
......
......@@ -33,5 +33,7 @@ void allocate_unn_cache(unn_cache_t *c, size_t num_nodes);
void allocate_romhom_workspace(rom_map_t *rom, int component_type);
void allocate_newton_cotes_workspace(knm_workspace_t *ws, surface_merged_map_t *map, int component_type);
void get_map_nr_definitions(int knum, int knmcmp, double nr1, double nr2, double *phi, surface_merged_map_t *map);
#endif /* KAT_KNM_INT_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment