GithubHelp home page GithubHelp logo

chaozhuang22 / comsol-matlab-livelink Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 0.0 21 KB

These are the MATLAB automation scripts for COMSOL topology optimization.

Home Page: https://chaozhuang22.github.io/fea/to/

MATLAB 100.00%

comsol-matlab-livelink's Introduction

COMSOL-MATLAB-livelink

This repository contains MATLAB .m files that automate topology optimization in COMSOL using the LiveLink interface. These files are associated with the research presented in this paper and in this article.

Why Is This Workflow Necessary?

In topology optimization, the slots usually reserved for parametric and auxiliary sweeps are already occupied by beta continuation and eta robust formulation. Therefore, an external control for parameter sweeping is required. This is particularly useful for handling cases with varying piezoresistor aspect ratios while maintaining a fixed area. The dimensions (length and width) of the piezoresistor are calculated using a separate function.

Workflow Overview

The main script performs the following steps:

  1. Generates a list of parameters based on a specified area and a provided list of aspect ratios.
  2. Feeds these parameters into the COMSOL optimization function.
  3. Produces optimized designs that meet the specified geometric constraints, using the function runParOptimization. Note: The optimization function is embedded within a parfor loop, which requires MATLAB's Parallel Computing Toolbox.

Usage

To use these scripts, place them in the same folder as your COMSOL .mph files. After specifying the path name variables, run the main.m script.

Troubleshooting

The connection between COMSOL and MATLAB can be vulnerable, often resulting in ambiguous errors that are difficult to interpret. If an error occurs:

  1. Verify if the parameters you are sweeping will cause errors in the original COMSOL .mph or not.
  2. If the .mph model is fine, proceed to debug the MATLAB script.

For example, a common error looks like the following:

Error using parallel.internal.pool.deserialize (line 45)
Unable to read data stream because the data contains a bad version or endian-key

Error in distcomp.remoteparfor/deserialize (line 284)
            data = parallel.internal.pool.deserialize(...

Error in distcomp.remoteparfor>@(data)deserialize(obj,data) (line 242)
            [err, workerAborted] = iIntervalErrorDispatch(r, @(data) deserialize(obj, data));

Error in distcomp.remoteparfor>iIntervalErrorDispatch (line 547)
            origErr = deserFcn(intervalError);

Error in distcomp.remoteparfor/handleIntervalErrorResult (line 242)
            [err, workerAborted] = iIntervalErrorDispatch(r, @(data) deserialize(obj, data));

Error in distcomp.remoteparfor/getCompleteIntervals (line 395)
                            [r, err] = obj.handleIntervalErrorResult(r);

Error in scriptForAspectRatioAndPositionSweep (line 25)
parfor i = 1:length(jobSequence)

Solution:

  1. Check if variable names in loadAndSetupModel() match with the variables defined in the .mph file.
  2. Check if the study nodes (e.g. std1) specified in runAndVerifyModel() match with the study node tag in the .mph file.
  3. Make sure the generic COMSOL can build that specified geometry.

comsol-matlab-livelink's People

Contributors

chaozhuang22 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.