Skip to content

Commit

Permalink
Support latest ansys electronic executable
Browse files Browse the repository at this point in the history
Use find_ansys_executable to detect ansys executable on the current
system looking from default installation locations.

Uses latest windows default installation location if Ansys is not found
on current machine. This is useful if external simulation machine is used.
  • Loading branch information
jukkarabina committed Feb 7, 2024
1 parent 53bf4e7 commit 68c1f4a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions klayout_package/python/kqcircuits/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from pathlib import Path

from kqcircuits.pya_resolver import pya
from kqcircuits.util.defaults_helper import find_ansys_executable
from kqcircuits.util.import_helper import module_from_file


Expand Down Expand Up @@ -52,8 +53,7 @@

TMP_PATH.mkdir(parents=True, exist_ok=True) # TODO move elsewhere?

ANSYS_EXECUTABLE = r"%PROGRAMFILES%\AnsysEM\v232\Win64\ansysedt.exe" # default Ansys executable location in Windows
# ANSYS_EXECUTABLE = "/opt/AnsysEM/v232/Linux64/ansysedt" # default Ansys executable location in Linux
ANSYS_EXECUTABLE = find_ansys_executable(r"%PROGRAMFILES%\AnsysEM\v241\Win64\ansysedt.exe")
ANSYS_SCRIPT_PATHS = [SCRIPTS_PATH.joinpath("simulations").joinpath("ansys")]
ELMER_SCRIPT_PATHS = [SCRIPTS_PATH.joinpath("simulations").joinpath("elmer")]
XSECTION_PROCESS_PATH = ROOT_PATH.joinpath("xsection/kqc_process.xs")
Expand Down
34 changes: 34 additions & 0 deletions klayout_package/python/kqcircuits/util/defaults_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This code is part of KQCircuits
# Copyright (C) 2024 IQM Finland Oy
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program. If not, see
# https://www.gnu.org/licenses/gpl-3.0.html.
#
# The software distribution should follow IQM trademark policy for open-source software
# (meetiqm.com/developers/osstmpolicy). IQM welcomes contributions to the code. Please see our contribution agreements
# for individuals (meetiqm.com/developers/clas/individual) and organizations (meetiqm.com/developers/clas/organization).

import os
from pathlib import Path


def find_ansys_executable(default):
"""Finds latest Ansys Electronics executable from default installation locations. Returns 'default' if not found.
"""
paths = [(Path(os.environ.get("ProgramFiles", r"C:\Program Files")).joinpath("AnsysEM"), r"Win64\ansysedt.exe"),
(Path("/opt/AnsysEM"), "Linux64/ansysedt")]
for root, exe in paths:
if os.path.isdir(root):
versions = sorted([f for f in os.listdir(root) if f.startswith("v")], reverse=True)
for version in versions:
executable = root.joinpath(version).joinpath(exe)
if os.path.isfile(executable):
return executable
return default

0 comments on commit 68c1f4a

Please sign in to comment.