Without pre rendering (no FreeCAD STL) - adamfrees/comsol-builder GitHub Wiki
This method is more light-weight but potentially less accurate. It is best used in cases in which there are no overlapping electrodes (such as in a "stadium-style" device), or for building simple prototyping models. This allows for a simple extrusion of 2D electrode designs.
An example of this process can be found in examples/from_dxf/test_device.java
. To build this example on Linux/MacOS, after set-up run:
./generate_mph examples/from_dxf/test_device.java
from the comsol-builder
directory.
Set-up
The comsol-builder application requires an active COMSOL installation and a standard installation of Java. Note that COMSOL requires the purchase of a license.
(Linux/MacOS): make sure that the COMSOL path in generate_mph
is correct. The default is comsolPath="/Applications/COMSOL54/Multiphysics"
, which should be correct for COMSOL version 5.4 running on MacOS.
Building COMSOL file (Linux/MacOS)
For Linux and MacOS, a COMSOL file can be generated from a 2D DXF file by running from this repository ./generate_mph /path/to/file/javaFile.java
, where javaFile.java
is a Java file with some information about the device's materials and heterostructure. An example Java file can be found at examples/from_dxf/test_device.java
in this repository.
generate_mph
is a bash file which performs 5 steps:
-
javac -d . -cp "$comsolPath/plugins/*" -source 8 -target 8 src/*
: Compiles (using Java 8) the classes contained in thesrc
folder, placing the compiled .class files into a package foldercomsolbuilder
. -
javac -cp "$comsolPath/plugins/*":"." -source 8 -target 8 $javaFile
: Compiles (using Java 8) the input Java file, writing the results into a .class file. -
jar -cvf comsolbuilder.jar comsolbuilder/*
: Takes the package folder created in step 1 and creates a package filecomsolbuilder.jar
. -
$comsolPath/bin/comsol batch -dev $PWD/comsolbuilder.jar -inputfile $PWD/${javaFile::${#javaFile}-5}.class -outputfile $PWD/${javaFile::${#javaFile}-5}.mph
: Uses thecomsol batch
command to run the compiled Java code, and write the results to disk in a COMSOL .mph file. -
Delete intermediate .class and .jar files.
Building COMSOL file (Windows)
Bash files do not run on Windows, so the 5 steps outlined in the previous section need to be run individually.