HomerReid / scuff-em

A comprehensive and full-featured computational physics suite for boundary-element analysis of electromagnetic scattering, fluctuation-induced phenomena (Casimir forces and radiative heat transfer), nanophotonics, RF device engineering, electrostatics, and more. Includes a core library with C++ and python APIs as well as many command-line applications.
http://www.homerreid.com/scuff-em
GNU General Public License v2.0
125 stars 50 forks source link

Building Scuff in Windows #230

Open DAWardle opened 3 years ago

DAWardle commented 3 years ago

Hi everyone.

I'm trying to build Scuff in MS Windows. From "Scuff-EM on Windows" (https://github.com/HomerReid/scuff-em/issues/133) I gather this must be possible so I'm trying to reproduce what they have done.

I've installed MinGW (https://osdn.net/projects/mingw) and use this for the build. I configure scuff with:

./configure --enable-maintainer-mode "$@" --prefix=C:/MinGW/msys/1.0/home/dward/scuff-em-installation --without-openmp --without-hdf5 --with-blas=C:/MinGW/msys/1.0/home/dward/OpenBLAS-.3.13/libopenblas_opteronp-r0.3.13.a --without-python

I'm not sure if the configure proceeds correctly --- it outputs a lot of dialogue and I don't know what the dialogue should read --- having a typical dialogue available would be helpful --- but it does end with Now type 'make' to compile and sudo 'make install'.

When I make it seems to start in \libs\libhrutil. It gets through libhrutil.cc with some warnings and ProcessArguments.cc and ProcessOptions.cc without incident. It then has a go at Vector.cc and exits with this error:

Vector.cc: In function 'double randU(double, double)': Vector.cc:464:23: error: 'random' was not declared in this scope; did you mean 'randN'? 464 | { return A + (B-A) random() (1.0 / RAND_MAX); } .........|........................................^~ .........|........................................randN make[3]: *** [Vector.lo] Error 1

This has me completely stuck. If anyone can offer any help, I'd be very appreciative.

DAWardle commented 3 years ago

I've taken a different approach and have scuff-em running using Docker.

jfeist commented 3 years ago

I just updated the Docker image to use the latest version of scuff-em. I've actually used the fork of @texnokrates (https://github.com/texnokrates/scuff-em), as that has some additional patches on top of the last version in this repository. Let me know if this works as well.

DAWardle commented 3 years ago

Hi Johannes.

First of all, many thanks for all the work you've done on this.

There is good news and bad news.

The good news: I got Windows 10 up-to-date, uninstalled Docker and installed the latest version, pulled your new Docker image of scuff, ran the Mie Scattering example, and the output matches scuff-em-master\doc\docs\examples\MieScattering\SiCData.png. Actually the match isn't perfect, but this might be OK. I think the new Docker image might also run faster than the previous image, although I have no need for speed.

The bad news: Using scuff-scatter, the absorbed power reported in the PFT file appears incorrect if the incident field is composed of more than one field. So, for example, I run the Mie scattering example three different ways (which should be identical):

  1. By putting in the Args file: pwDirection 0 0 1 pwPolarization 1 0 0 (This is as originally specified in the example.)

  2. By putting in the Args file: pwDirection 0 0 1 pwPolarization 0.5 0 0 pwDirection 0 0 1 pwPolarization 0.5 0 0

  3. By using this IFFile: TestWave PW 0 0 1 0.5 0 0 PW 0 0 1 0.5 0 0 END

The waves in 2 and 3 add to give the wave in 1, so the results for 1, 2, and 3 should be the same. But here are the outputs in the PFT file at a frequency of 0.1:

1: 0.1 TheSphere 1.440454e-07 5.721606e-07 -1.924764e-13 ...

2: 0.1 TheSphere -2.140576e-07 5.721606e-07 -1.924764e-13 ...

3: 0.1 TestWave TheSphere -2.140576e-07 5.721606e-07 -1.924764e-13 ...

Here the fourth column (fifth column in the case of 3) is the scattered power and all three are the same so that's good. The third column (fourth in the case of 3) is the absorbed power and 1 matches scuff-em-master\doc\docs\examples\MieScattering\SiCData.png which is good but 2 and 3 do not match 1 which is bad and, in fact, they are negative, which seems implausible. Unfortunately I didn't try this check on the previous Docker image. But I did try adding fields similar to 2 in a different geometry. The absorbed powers were positive numbers (unfortunately I have no way of knowing if they are the correct positive numbers). I have rerun the geometry and I now have negative numbers for the absorbed power, so the new image is definitely worse than the old image in this regard. If this issue is not confined to the Docker image then it might be a serious issue for all scuff-scatter users.

Yours sincerely,

David Wardle.

jfeist commented 3 years ago

Hi David, I see, that seems like a problem. Unfortunately, I don't really have time to debug this myself, but you could simply clone my scuff-em-docker repository (https://github.com/jfeist/scuff-em-docker) and modify the Dockerfile to see if that helps. In particular, you can just change the second line in the second RUN command in the Dockerfile to something else, e.g., replace

git clone https://github.com/texnokrates/scuff-em.git

with

git clone https://github.com/HomerReid/scuff-em.git

to use the latest master by Homer. Then you just run docker build -t scufftest . in the directory with the Dockerfile to build an image tagged as scufftest, and then you can do docker run scufftest args... to check if it works.

If the latest master by Homer doesn't show this problem, let me know and I'll change the image on docker hub to use that. Probably @texnokrates would also be interested, I don't think his changes are supposed to introduce any new bugs... If using Homer's repository doesn't help, you could go back in the history to check if you find a commit that does. To checkout a specific commit, you'd have to replace

RUN cd /tmp && \
    git clone https://github.com/texnokrates/scuff-em.git && \
    cd scuff-em && \
    ./autogen.sh ...

with

RUN cd /tmp && \
    git clone https://github.com/texnokrates/scuff-em.git && \
    cd scuff-em && \
    git checkout <HASH> && \
    ./autogen.sh ...

where <HASH> is the hash of the commit you want, and then again rebuild the docker image.

DAWardle commented 3 years ago

Hi Johannes.

I found the information you've provided about making Docker images really helpful (so helpful in fact that I've turned them into a new wiki page).

I've also narrowed down when the bug first appeared. I've summarized all the information I have about the bug in a new issue (because it's distinct from the topic of this issue).

I leave it over to you to notify @texnokrates as I'm not sure how to do that.

Yours sincerely,

David Wardle.

texnokrates commented 3 years ago

Hi David, don't worry, I get notifications from all issues here.

(So the bug apparently isn't "mine", which is good to see.)