Cube - Inverse Calculation ************************** The inverse calculation searches the geometric designs that closely matches user preferred mechanical property over the defined domain. For instance, user would like to have a lattice structure has overall elastic modulus of 79GP with Ti64 material, the Cube API can calculate the closest solution in a few seconds for the user selected lattice and defined size domain. ========== Conditions ========== Cube calculates the requested quantity through the stress-strain curve under condition of the sample block compressed by 2mm. In some cases, the plastic deformation may not be reached. The requested input and output are in SI unit. .. list-table:: :widths: 25 25 25 25 :header-rows: 1 * - Force - Displacement - Time - Stress * - Newton, N - Meter, m - Seconds, s - Pascal, Pa ========= Arguments ========= .. list-table:: :widths: 25 25 50 :header-rows: 1 * - Argument - Type - Description * - ``Token`` - string, single element list - User token for verification purpose. * - ``Lattice`` - string, single element list - Name of lattice requested * - ``Profile`` - string, single element list - Cross-sectional profile of the beam. Two options are avaiable, "C" for the circule shape and "R" for Square shape. * - ``Material`` - string, single element list - Defines the base material of lattice structure. For Cube product, three materials are avaiable, Ti64, Inconl. * - ``cmd`` - string, single element list - requested operations. * - ``TargetE`` - float number, single element list - The requested Young's modulus. The parameter is requried for the inverse calculation on the geometric factors (e.g. x, y, z and Thk). * - ``Thk_ub`` - float number, single element list - Upper bounds of the beam profile * - ``Thk_lb`` - float number, single element list - Lower bounds of the beam profile * - ``x_ub`` - float number, single element list - Upper bounds of cell width in x direction * - ``x_lb`` - float number, single element list - Lower bounds of cell width in x direction * - ``y_ub`` - float number, single element list - Upper bounds of cell width in x direction * - ``y_lb`` - float number, single element list - Lower bounds of cell width in x direction * - ``z_ub`` - float number, single element list - Upper bounds of cell width in x direction * - ``z_lb`` - float number, single element list - Lower bounds of cell width in x direction The table below shows the possible selections of the parameter values. .. list-table:: :widths: 25 75 :header-rows: 1 * - Parameters - Values * - ``Lattice`` - ``PrimCubic``, ``BC``, ``BCCubic``, ``FCCubic``, ``EdgeOcta``, ``NaCL``, ``StarTet``, ``BCStarTet``, ``OctaTet``, ``Dodecahedron``, ``Tetrahedral`` * - ``Material`` - ``Ti64``, ``Inconl_718``, ``AlSi10Mg`` * - ``Profile`` - ``C``, ``R`` * - ``cmd`` - ``invE``, ``invE_BC``, ``minE_BC`` The key ``cmd`` controls the a series of requested operation as explained below. .. list-table:: :widths: 25 75 :header-rows: 1 * - ``cmd`` value - Description * - ``invE`` - Calculating the geometric factor, i.e. ``x``, ``y``, ``z`` and ``Thk``, that the overall response closes to the defined ``targetE``. Searching domain definition are not required in this request. * - ``invE_BC`` - search the defined geometric domain to find the closest match to the given Young's modulus. * - ``minE_BC`` - search the defined geometric domain to find the minimum Young's modulus. ``targetE`` is not required in this case. * - ``maxE_BC`` - search the defined geometric domain to find the maximum Young's modulus. ``targetE`` is not required in this case. ======= Returns ======= Returned fields are corresponding to the operation key ``cmd``, explained below. A general field ``Msg`` in all returned results contains error or successful information. .. list-table:: :widths: 25 25 25 25 :header-rows: 1 * - ``cmd`` value - Returned fields - Type - Description * - ``invE`` - ``x``, ``y``, ``z``, ``Thk``, ``E_diff`` and ``Msg`` - float, single element list - ``x``, ``y``, ``z`` and ``Thk`` are geometric factors. ``E_diff`` shows the difference between solution and target. ``Msg`` showed whether the computation was successful. * - ``invE_BC`` - ``x``, ``y``, ``z``, ``Thk``, ``E_diff`` and ``Msg`` - float, single element list - ``x``, ``y``, ``z`` and ``Thk`` are geometric factors. ``E_diff`` shows the difference between solution and target. ``Msg`` showed whether the computation was successful. * - ``minE_BC`` - ``x``, ``y``, ``z``, ``Thk`` and ``Msg`` - float, single element list - ``x``, ``y``, ``z`` and ``Thk`` are geometric factor. ``Msg`` showed whether the computation was successful. * - ``maxE_BC`` - ``x``, ``y``, ``z``, ``Thk`` and ``Msg`` - float, single element list - ``x``, ``y``, ``z`` and ``Thk`` are geometric factor. ``Msg`` showed whether the computation was successful. ======== Examples ======== **Example 1: Search the global solution of geometric design of FUCubic lattice that produces the overall elastic modulus 2.0E+8Pa** The python example code is below .. code-block:: python import requests, json # Endpoint url cube_url = "http://cube.bleemcube.com/" # User token Token = "f3aa3c11-2817-4a73-993c-db9a62a0ada7" # Body data section includes all information and data for calculation. data = { "Lattice": ["FCCubic"], "Profile": ["C"], "Material": ["Ti64"], "cmd" : ["invE"], "Thk": ["0.0005123"], "TargetE": ["2.0E+08"] } # connects to API header = {"x-api-key":Token} r = requests.post(cube_url, data = json.dumps(data), headers=header) # convert returned bytes data to string responses = (r.content.decode("utf-8")).replace("\'","\"") # then convert string to dict re = json.loads(responses) print(re) User should see the results as below. .. code-block:: python {'Msg': 'OK', 'Thk': 0.0001305059783383738, 'x': 0.0075229189404850865, 'y': 0.008403907280997705, 'z': 0.006264339776133071, 'E_diff': 0.0018271803855895996} **Example 2: based on example 1, search the elastic modulus over the defined geometric domain** Update ``data`` in above codes as the one below .. code-block:: python data = { "Lattice": ["FCCubic"], "Profile": ["R"], "Material": ["Inconel_718"], "cmd" : ["invE_BC"], "Thk": ["0.0003"], "TargetE" : ["2.21345E+08"], "Thk_lb":[0.00001], "Thk_ub":[0.000043], "x_lb": [0.004], "x_ub": [0.005], "y_lb": [0.004], "y_ub": [0.005], "z_lb": [0.004], "z_ub": [0.005], } User shall expect the results like: .. code-block:: python {'Msg': 'OK', 'Thk': 3.55561791228093e-05, 'x': 0.00170937702863693, 'y': 0.0034239391103587083, 'z': 0.005668920196695159, 'E_diff': 0.000571131706237793}