GithubHelp home page GithubHelp logo

sblauth / cashocs Goto Github PK

View Code? Open in Web Editor NEW
50.0 3.0 9.0 71.4 MB

computational adjoint-based shape optimization and optimal control software for python

Home Page: https://cashocs.readthedocs.io/

License: GNU General Public License v3.0

Python 99.49% GLSL 0.51%
optimization python fenics

cashocs's People

Contributors

dependabot[bot] avatar pre-commit-ci[bot] avatar sblauth avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cashocs's Issues

[Development] File output for constrained problems

Constrained problems do print their progress only in the console - it would be beneficial if they would also have the possibility to print to file. This could be done using the same parameters as for usual optimization problems.

[Bug] docker images are not created correctly

Docker images build fails when calling conda clean -tipsy.
Apparently, this is related to conda v22.11.1 which is now the latest image on dockerhub.
Possible workaround: use conda clean --all or similar

[Development] Improve cashocs memory management

Is your feature request related to a problem? Please describe.
cashocs may use a lot of memory when either the systems are large or the geometry is large. Especially the matrices that have to be assembled use up a lot of memory, which could be used otherwise. They are kept in memory in order to speed up the assembly (which makes sense for small to medium problems).

Describe the solution you'd like
The system matrices could be reinitiated to clear memory in case a large problem is considered. Therefore, one should either check current memory status (might be difficult) or check the number of DoF's and the dimension of the problem (3D is harder than 2D, usually) and add a criteria, which state when memory is important.

[Bug] cashocs remesh files are sometimes not deleted

cashocs remeshing files are not deleted in case the remeshing succeeds, but the resulting mesh is not approved due to a mesh quality which is too low.

Proposed fix: Load the remeshing files also in the import_mesh step (which is where the exception is raised) and delete the corresponding directories.

[Development] Close XDMFFiles properly

Currently, the xdmf files for visualization are not really closed properly.

Suggestion: Wrap each call of write_checkpoint in a python "with" context manager, which looks like

with XDMFFile(mpi_comm_world(), 'name.xdmf') as xdmf:
xdmf.write(mesh)

contributing guidelines suggestion

Contributing guidelines state Use the same coding conventions as established in the project.
Might it be helpful to unpack this?
Or more explicitly adding flake8.

(I'm incredibly petty and get put off working with anything that isn't blacked.)

[Development] Curvature condition in L-BFGS

The curvature condition in the L-BFGS method says to discard the memory and re-start with steepest descent in case y \cdot s is not positive. To check this condition, we need a good relative (numerical) estimate, when this is "numerically close to 0". This should be further investigated.

[Development] Change the formatting of cashocs output

When cashocs is verbose, the output is something like:

Iteration i --- Cost Functional value: j --- Gradient norm: z

This could be changed to an (easier to read) format

iteration cost functional gradient norm
i j k
l m n
o p q

where the title row reappears every few (10 / 20) iterations.

[Feature Request] Change the formatting of cashocs (newton_solver, etc.) console output

Is your feature request related to a problem? Please describe.

Even after #56 there still exist a number of places, where cashocs printing to the console is sub-optimal, which could be improved by the same techniques used in #56.

Describe the solution you'd like

cashocs should use shorter output messages which are better to read and understand and also fit the default terminal size.

[Development] Advanced stepsize computation

One could try to implement a little more sophisticated stepsize computation, with different factors for increasing (when a step is accepted) and decreasing (when a step is rejected) the stepsize. Currently, there is only one factor.

Test fail : `test_scalar_multiple_norms`

Hello.
Cheers for this project.
A heads up on failing test.

$python -m pytest 
... 
========================================== FAILURES ==========================================
_________________________________ test_scalar_multiple_norms _________________________________

    def test_scalar_multiple_norms():
        config = cashocs.load_config(dir_path + "/config_ocp.ini")
    
        u.vector()[:] = 40
    
        J = Constant(0) * dx
        norm_y = y * y * dx
        norm_u = u * u * dx
        tracking_goals = [0.24154615814336944, 1554.0246268346273]
        J_y = {"integrand": norm_y, "tracking_goal": tracking_goals[0]}
        J_u = {"integrand": norm_u, "tracking_goal": tracking_goals[1]}
        J_scalar = [J_y, J_u]
        config.set("OptimizationRoutine", "initial_stepsize", "1e-4")
    
        test_ocp = cashocs.OptimalControlProblem(
            F, bcs, J, y, u, p, config, scalar_tracking_forms=J_scalar
        )
        test_ocp.solve(algorithm="bfgs", rtol=1e-6, max_iter=500)
    
>       assert 0.5 * pow(assemble(norm_y) - tracking_goals[0], 2) < 1e-3
E       AssertionError: assert (0.5 * 0.0057537558828288345) < 0.001
E        +  where 0.0057537558828288345 = pow((0.31739967409898506 - 0.24154615814336944), 2)
E        +    where 0.31739967409898506 = assemble(Form([Integral(Product(Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 11...agrange', triangle, 1), dim=2), 110), 'everywhere', {}, <dolfin.cpp.mesh.MeshFunctionSizet object at 0x7f5189016e70>)]))

tests/test_optimal_control.py:433: AssertionError

Possibly/ possibly not relevant : I did not use conda to install packages.

[Development] Implement other types of line search

More flexibility for the user. Possible options are:

  • A linearized exact line search (which would be exact for linear-quadratic problems)
  • An interpolation-based line search which would generate a quadratic / cubic model of the 1D problem and search for the minimizer of the model

[Development] Investigate alternative approaches for remeshing

Basically, restarting the script has several drawbacks (including that it makes using ConstrainedProblems and Space Mapping not possible yet), so this should be avoided.

Possible idea: Users could supply a factory for the input parameters depending on the mesh, so this function can be called each time the mesh changes. The classes then have to be reinstantiated and history has to be saved / passed to the newly instantiated objects.

[Bug] Printing is not consistent

When cashocs does not converge (e.g. due to max amount of iterations) the stats that are printed are not consistent, i.e. the final iteration has the same values as the one before it

[Bug] Constant functions cannot be saved to xdmf file

When using a constant function as (state) variable which should be saved to xdmf, this is currently not supported in FEniCS. Error message is along the lines of "Real element not supported".

Proposal: Catch this case and ensure that these variables are not saved for visualization.

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.