Exemplo n.º 1
0
def test_setting_pool_values():
    from compute import pool_definition_list as pool_function
    m = pool_function()
    m.set_value('Radius', '0.11*100 cm')
    v = m.get_value('Radius')
    assert v == 0.11, 'Wrong value %s, not 0.11' % v
    m.set_value('Radius', '0.11*100*exp(0.0)/100/1000 km')
    v = m.get_value('Radius')
    assert v == 0.11, 'Wrong value %s, not 0.11' % v
Exemplo n.º 2
0
def test_setting_pool_values():
    from compute import pool_definition_list as pool_function
    m = pool_function()
    m.set_value('Radius', '0.11*100 cm')
    v = m.get_value('Radius')
    assert v == 0.11, 'Wrong value %s, not 0.11' % v
    m.set_value('Radius', '0.11*100*exp(0.0)/100/1000 km')
    v = m.get_value('Radius')
    assert v == 0.11, 'Wrong value %s, not 0.11' % v
Exemplo n.º 3
0
import os
from compute import compute as compute_function

# Pool object (must be imported before model)
from compute import define_pool as pool_function

pool = pool_function()

# Can define other default values in a file: --poolfile name
from parampool.pool.UI import set_defaults_from_file

pool = set_defaults_from_file(pool)
# Can override default values on the command line
from parampool.pool.UI import set_values_from_command_line

pool = set_values_from_command_line(pool)

from flask import Flask, render_template, request
from model import Compute

# Application object
app = Flask(__name__)


# Path to the web application
@app.route('/', methods=['GET', 'POST'])
def index():
    form = Compute(request.form)
    if request.method == 'POST':  # and form.validate():

        # Send data to Pool object
from compute import compute_motion_and_forces_with_pool as compute_function

# Pool object (must be imported before compute_motion_and_forces_with_pool_pool_definition_api_models
from compute import pool_definition_api as pool_function
pool = pool_function()

# Can define other default values in a file: --poolfile name
from parampool.pool.UI import set_defaults_from_file
pool = set_defaults_from_file(pool)
# Can override default values on the command line
from parampool.pool.UI import set_values_from_command_line
pool = set_values_from_command_line(pool)

from django.shortcuts import render_to_response
from django.template import RequestContext
from compute_motion_and_forces_with_pool_pool_definition_api_models import MotionAndForcesWithPool, MotionAndForcesWithPoolForm

def index(request):
    result = None

    form = MotionAndForcesWithPoolForm(request.POST or None)
    if request.method == 'POST' and form.is_valid():
        for field in form:
            name = MotionAndForcesWithPool._meta.get_field(field.name).verbose_name.strip()
            value = field.data
            pool.set_value(name, value)
        result = compute(pool)
        form = MotionAndForcesWithPoolForm(request.POST)

    return render_to_response(
        "compute_motion_and_forces_with_pool_pool_definition_api_index.html",