From: Jeff on
Hey all -

So I am trying to Matlab in conjunction with a COMSOL function file to find the optimum geometric parameters for a PEM fuel cell catalyst layer. My model is very simple, consisting of two adjoining rectangles of height H and widths epsilon and (1-epsilon) respectively.

The geometry is defined as follows:

g1=square2('1',H,'base','corner','pos',{'0','0'},'rot','0');
g1=rect2((1-epsilon),H,'base','corner','pos',{epsilon,'0'},'rot','0');

The objective function is simply to minimize catalyst_volume = (1-epsilon)*H (this is the primary output of the COMSOL file), with respect to upper and lower bounds and one nonlinear constraint.

The design parameters that I wish to optimize are epsilon and H. Using the fmincon function in Matlab I constrain epsilon to be between 0.1 and 0.9, and H to be greater than 0.

The nonlinear constraint comes from a secondary output of the COMSOL file called "Yield". I specify a nonlinear equality such that Yield - *value* = 0.

When I attempt to run the simulation the solver will go though one or two iterations (changing the system geometry) and then the following error arises:

Exception:
com.femlab.util.FLException: Edge length has to be greater than zero
Messages:
Edge length has to be greater than zero
Error in ==>
g2=react2((1-epsilon), H, ...

I have narrowed the problem down to something with the epsilon value and the nonlinear output constraint, somehow this parameter (epsilon) is becoming either negative or zero.

I believe my problem to be with the nonlcon function used by fmincon. which is defined as follows:

function[c,ceq] = nonlcon(x)
global Yield % This is the secondary output taken from COMSOL function file
Y = Yield - 3886;
c = [];
ceq = Y;
end

In this function I pass in the vector 'x' but do not use it to directly compute anything (it is used in the COMSOL file to give a value of 'Yield'). I'm wondering is this is where the issue may be?

Anyone have any ideas what may be going wrong?

Thank you,
Jeff