System of non linear differential equation numerical solution - numerical-methods

I am trying to solve a system of non-linear differential equations. My system has 15 parameters which I have to estimate, I am using optimization for it. Some of parameters can make my system be stiff and some maybe not. This can make my optimization result become garbage because the ODE solver terminates with an error. What is the best way to deal with such problem?
If I solve it with an implicit method, maybe my system will be not stiff, will it be ok? If yes what is the best numerical method you suggest.
Thanks a-lot.

Related

NAN during numerical solution of poisson equation

I am solving Poisson Equation for heterostructure (AlGaN-GaN system specifically) using SOR method, in FORTRAN. For a specific initialization, the solver gives NAN as output and stops (as I have set the ffpe-trap flag), and for a different initialization the solver runs well.
Should the solution of the poisson equation depend on the choice of the initial potential?
How do I understand the reason for NAN in general iteration method?
The more aggressive solvers converge faster, but tend to have also a smaller basin of attraction. If you start too far away from that, you might enter regions where the method becomes ill-conditioned. This could be caused by too much of the over-relaxation in the SOR method.
It may also happen that the solver diverges, a good solver should check for such rapidly increasing iteration sequences.
Of course, it could also be a "stupid" error in encoding the problem, for that automatic translators from mathematical formulas to the mesh grid equations were invented.
Without more details on the problem and the origin of the error, there is nothing more specific to be said. If you suspect a problem in the encoding of the discretized PDE, then add code here. If you think the problem is more related in the solver setup, or the solver itself, ask a question with more details in scientific computing, scicomp.SE.

Goal Seek in Octave to replicate Excel's 'Solver' Macro

This is essentially a question on fundamentals, and whether or not there is a more efficient way to achieve what I am looking for. I have built a working fluid dynamics calculator in Excel to find the flow rates required for a target pressure loss, the optimisation is handled using Solver but it's very clunky and not user friendly.
I'm trying to replicate the function in Octave since it's widely used here, but I am a complete beginner; I'm probably missing something obvious. I can easily enter all of the math for a single iteration via a series of functions, but my excel file required using the 'Solver' macro, and I'm unsure how to efficiently replicate this in Octave.
I am aware that linprog (in matlab) and glpk (octave) can be used to solve systems of linear equations.
I have a series of nested equations which are all dependant on a single matrix, Q (flow rates at various locations). Many other inputs are required, but they either remain constant throughout calculation (e.g. system geometry) or are dictated by Q (e.g. Reynolds number and loss coefficients). In trying to simplify my problem I have settled on two steps:
Write code to solve my problem, input: Q matrix, output: pressure loss matrix
Create a loop that iterates different Q matrices until some conditions for the pressure loss matrix are met.
I don't think it will be practical to get my expressions into the form of A*x = B (in order to use glpk) given the complexity. In excel, I can point solver at a Q value that drives a multitude of equations that impact pressure loss, and it will find the value I need to achieve a target. How can I most efficiently replicate this functionality in Octave?
First off all Solver is not a macro. Pretty far from.
So, you're going to replicate a comprehensive "What-If" Analysis Plug-in -- so complex in fact, that Microsoft chose to contract a 3rd Party company of experts to develop the tool and provide support for it (successfully based on the 1.2 Billion copies they've distributed).
And you're going to this an inferior coding language that you're a complete beginner with? Cool. I'd like to see this!
Cool. Here's a checklist of Solver's features, so you don't miss anything:
Good Luck!
More Information:
Wikipedia : Solver
Office.com : Define and Solve a Problem by using Solver
Frontline: Official Solver Page: http://solver.com
AppSource.Microsoft.com : Solver (with Video)
Frontline:L Solver International Manazine

Why neural network tends to output 'mean value'?

I am using keras to build a simple neural network for a regression task.
But the output is always tends to the 'mean value' of ground truth y data.
See the first figure, blue is ground truth, red is predicted value (very close to the constant mean of ground truth).
Also the model stops learning very early even though I set a learning epoch=100.
Anyone have ideas under what kinds of conditions the neural network will stop learning early and why the regression output tends to 'the mean' of ground truth?
Thanks!
Possibly because the data are unpredictable....? Do you know for certain that the data set has N order predictability of some kind?
Just eyeballing your data set, it lacks periodicity, lacks homoscedasticity, it lacks any slope or skew or trend or pattern... I can't really tell if there is anything wrong with your 'net. In the absence of any pattern, the mean is always the best prediction... and it is entirely possible (although not certain) that the neural net is doing its job.
I suggest you find an easier data set, and see if you can tackle that first.
The model is not learning from the data. Think of a basic linear regression - the 'null' prediction, the prediction if you didn't have any predictors at all, is just the expected value; i.e. the mean. It could be caused by many different issues, but initialization comes to mind - bad initialization leads to no learning. This blog post has good practical advice that may help.

How to implement fixed parameters in caffe?

Suppose there are parameters in the network I would like to change manually in pycaffe, rather than update automatically by the solver. For example, suppose we would like to penalize dense activations, this can be implemented as an additional loss layer. Across the training process, we would like to change the strength of this penalty by multiplying the loss with a coefficient that evolves in a pre-specified way. What would be a good way to do this in caffe? Is it possible to specify this in the prototxt definition? In the pycaffe interface?
Update: I suppose setting lr_mult and decay_mult to 0 might be a solution, but seems like a clumsy one. Maybe a DummyDataLayer providing the parameters as a blob would be a better option. But there is so little documentation that it's quite a struggle to write for someone new to caffe
Maybe this is a trivial question, but just in case someone else might be interested, here is a successful implementation I ended up using
In the layer proto def, set lr_mult and decay_mult to 0, which means that we neither want to learn or decay the parameters. Use filler to set initial values. To change the parameters in python during training of the network, use a statement like
net.param['name'][index].data[...] = something

cloth sim with implicit integration unstable problem

Im implementing a gpu based cloth simulation using mass-spring model with a backward euler integration.
The linear system is solved by using the conjugate gradient solver with filter. Everything is done in GPU.
I think as an implicit integration it should be stable like many paper pointed out, but it is unstable just like
the emplicit method. Most of time, when the time step size reaches a certain value (depending on the stiffness), the CG refuses to converge and goes into a infinite loop.
Although I've checked the code over and over again and read many papers, I still couldn't find out the reason.
The cloth moves correctly and the animation is much more convincible than the one using explicit integration, so i guess
the forces are computed correctly. Is there anything I missed to cause the instability?
I've been tackled by this strange problem for days......
Any one can help? any suggestion i would really appreciate
thanks alot in advance!